Skip to content

Commit d5a2e0e

Browse files
committed
Query filter block: Restrict key handling to only when the modal is open
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
1 parent 4c5d050 commit d5a2e0e

File tree

1 file changed

+5
-0
lines changed
  • mu-plugins/blocks/query-filter/src

1 file changed

+5
-0
lines changed

mu-plugins/blocks/query-filter/src/view.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ const { actions } = store( 'wporg/query-filter', {
8787
},
8888
handleKeydown: ( event ) => {
8989
const context = getContext();
90+
// Only handle key events if the dropdown is open.
91+
if ( ! context.isOpen ) {
92+
return;
93+
}
94+
9095
// If Escape close the dropdown.
9196
if ( event.key === 'Escape' ) {
9297
actions.closeDropdown();

0 commit comments

Comments
 (0)