Skip to content

Commit 522404a

Browse files
committed
fix: skip menu shortcut for modified
fixes hijacking higher-level keyboard shortcuts for browser or system when using numbers with cmd/windows/option/alt/control/shift keys
1 parent ba29af3 commit 522404a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/Nav/Menu/useNavMenu.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { useState } from "react"
22
import type { MotionProps } from "framer-motion"
33
import { useEventListener } from "@chakra-ui/react"
44

5+
import { isModified } from "@/lib/utils/keyboard"
6+
57
import { MAIN_NAV_ID, SECTION_LABELS } from "@/lib/constants"
68

79
import type { NavSectionKey, NavSections } from "../types"
@@ -16,7 +18,7 @@ export const useNavMenu = (sections: NavSections) => {
1618

1719
// Focus corresponding nav section when number keys pressed
1820
useEventListener("keydown", (event) => {
19-
if (!document || !event.key.match(/[1-9]/)) return
21+
if (!document || !event.key.match(/[1-9]/) || isModified(event)) return
2022
if (event.target instanceof HTMLInputElement) return
2123
if (event.target instanceof HTMLTextAreaElement) return
2224
if (event.target instanceof HTMLSelectElement) return

0 commit comments

Comments
 (0)