Skip to content

Commit

Permalink
Avoid both events firing, and avoid modifying tab behavior when a reg…
Browse files Browse the repository at this point in the history
…ion is focused
  • Loading branch information
gwwar committed Jun 29, 2021
1 parent ff111d9 commit 6d5a131
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ export default function useTabNav() {
if ( event.keyCode !== TAB ) {
return;
}

if ( event.target?.getAttribute( 'role' ) === 'region' ) {
return;
}

if ( container.current === event.target ) {
return;
}

const isShift = event.shiftKey;
const direction = isShift ? 'findPrevious' : 'findNext';
const target = focus.tabbable[ direction ]( event.target );
Expand Down

0 comments on commit 6d5a131

Please sign in to comment.