Skip to content

Commit f0e3ad4

Browse files
committed
skip modal dialog elements in useRovingTabIndex
1 parent 9bcec87 commit f0e3ad4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/TreeView/useRovingTabIndex.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export function useRovingTabIndex({
2222
getNextFocusable: (direction, from, event) => {
2323
if (!(from instanceof HTMLElement)) return
2424

25+
// Skip elements within a modal dialog
26+
// This need to be in a try/catch to avoid errors in
27+
// non-supported browsers
28+
try {
29+
if (from.closest('dialog:modal')) {
30+
return
31+
}
32+
} catch {
33+
// Don't return
34+
}
35+
2536
return getNextFocusableElement(from, event) ?? from
2637
},
2738
focusInStrategy: () => {

0 commit comments

Comments
 (0)