Skip to content

Commit

Permalink
Query filter block: Restrict key handling to only when the modal is open
Browse files Browse the repository at this point in the history
Previously, the key handler would try to run when the button was focused, but the modal was closed. Without having focusable elements set, this would cause the tab & shift+tab behavior to break. Restricting to the open modal keeps the focus-trap working when open.

Fixes #471
  • Loading branch information
ryelle committed Dec 3, 2024
1 parent 4c5d050 commit d5a2e0e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mu-plugins/blocks/query-filter/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ const { actions } = store( 'wporg/query-filter', {
},
handleKeydown: ( event ) => {
const context = getContext();
// Only handle key events if the dropdown is open.
if ( ! context.isOpen ) {
return;
}

// If Escape close the dropdown.
if ( event.key === 'Escape' ) {
actions.closeDropdown();
Expand Down

0 comments on commit d5a2e0e

Please sign in to comment.