Skip to content

Commit

Permalink
Remove itself when the trap loses focus.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Sep 26, 2022
1 parent 739b7b4 commit a12ad38
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/compose/src/hooks/use-constrained-tabbing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ function useConstrainedTabbing() {

trap.tabIndex = -1;
node[ domAction ]( trap );

// Remove itself when the trap loses focus.
trap.addEventListener( 'blur', () => node.removeChild( trap ) );

trap.focus();
// Remove after the browser moves focus to the next element.
timeoutId = setTimeout( () => node.removeChild( trap ), 10 );
}

node.addEventListener( 'keydown', onKeyDown );
Expand Down

0 comments on commit a12ad38

Please sign in to comment.