-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix navigation in inserter menu triggering writing flow #11088
Fix navigation in inserter menu triggering writing flow #11088
Conversation
@talldan thanks for working on this! Tested and works for me. Worth noting left / arrow keys for Just wondering if for the future a more abstracted solution could be valuable, as in: giving the ability to components to not trigger WritingFlow. |
Preventing propagation ensures that ObserveTyping will no longer trigger the startTyping action, which transfers focus back to the block level.
…veTyping component.
2893ac9
to
c9d8e43
Compare
Seems like something good to consider. I don't see it as blocking for the PR though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
I think we should change the position of |
Description
Fixes #9583
Particular keyboard interaction (up/down arrow keys) was causing focus to transfer out of the default block's insertion menu.
What causes this?
As far as I can tell, the ObserveTyping component is receiving those events and triggering the START_TYPING action, potentially causing focus to transfer to a block:
gutenberg/packages/editor/src/components/observe-typing/index.js
Lines 165 to 171 in a696e50
There might also be other event handlers acting on those events, but if so I haven't been able to determine what they are.
The fix
In this PR I've used the same technique as used in the LinkContainer to prevent this:
gutenberg/packages/editor/src/components/rich-text/format-toolbar/link-container.js
Lines 59 to 64 in a696e50
☝️ Here onKeyPress and onKeyDown events are used to prevent propagation of keyboard events outside of the popover. I've applied the same to the block insertion menu.
How has this been tested?
Manual testing
1 - Open the inserter menu from the default block
2 - Press the up or down arrow key
Expected - focus should remain within the inserter search input
Actual - focus is taken to a block
Added an e2e test to catch regressions
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: