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 25, 2021
1 parent eb25347 commit a48bb37
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 a48bb37

Please sign in to comment.