Skip to content

Commit 62e0e4d

Browse files
authored
don't let route tabs eat cmd+arrow keypresses (#3020)
1 parent c916d66 commit 62e0e4d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/components/RouteTabs.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import type { ReactNode } from 'react'
1010
import { Link, Outlet } from 'react-router'
1111

1212
import { useIsActivePath } from '~/hooks/use-is-active-path'
13-
import { KEYS } from '~/ui/util/keys'
13+
import { hasModifier, KEYS } from '~/ui/util/keys'
1414

1515
const selectTab = (e: React.KeyboardEvent<HTMLDivElement>) => {
16+
// Don't intercept modified arrow keys (Cmd for browser back/forward, etc.)
17+
if (hasModifier(e)) return
18+
1619
const target = e.target as HTMLDivElement
1720
if (e.key === KEYS.left) {
1821
e.stopPropagation()

app/ui/util/keys.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ export const KEYS = {
2121
space: ' ',
2222
escape: 'Escape',
2323
} as const
24+
25+
/** Returns true if any modifier key is held */
26+
export const hasModifier = (
27+
e: Pick<KeyboardEvent, 'metaKey' | 'ctrlKey' | 'shiftKey' | 'altKey'>
28+
) => e.metaKey || e.ctrlKey || e.shiftKey || e.altKey

0 commit comments

Comments
 (0)