-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Refactor useCanContextualToolbarShow for simplicity and clarity #56914
Refactor useCanContextualToolbarShow for simplicity and clarity #56914
Conversation
- Rename to useCanBlockToolbarBeFocused: Each usage of useCanContextualTool barShow ended up as one blockToolbarCanBeFocused const. - The scenarios of when the block toolbar can be focused was much simpler t han the implemented checks. Refactored for the scenarios in which it can be focused.
Size Change: -903 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in 8a39e75. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7146283837
|
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.
The fact that no tests fail and none are changed seems dubious with these refactors. That plus the instruction to
Test alt+f10 shortcut in many scenarios.
makes me think this PR or an immediate follow up should include some tests for common scenarios - basically the ones in the hook comment.
Manual testing works 👏🏻 and found a typo.
packages/block-editor/src/utils/use-can-block-toolbar-be-focused.js
Outdated
Show resolved
Hide resolved
…ed.js Co-authored-by: Andrei Draganescu <[email protected]>
* Refactor useCanContextualToolbarShow for simplicity and clarity - Rename to useCanBlockToolbarBeFocused: Each usage of useCanContextualTool barShow ended up as one blockToolbarCanBeFocused const. - The scenarios of when the block toolbar can be focused was much simpler t han the implemented checks. Refactored for the scenarios in which it can be focused. * Update packages/block-editor/src/utils/use-can-block-toolbar-be-focused.js Co-authored-by: Andrei Draganescu <[email protected]> --------- Co-authored-by: Ben Dwyer <[email protected]> Co-authored-by: Andrei Draganescu <[email protected]>
What?
Simplify conditions of useCanContextualToolbarShow and turn it into useCanBlockToolbarBeFocused, which is what all the implementors of useCanContextualToolbarShow were doing.
Why?
Since #56335 is merged, the conditions for when the toolbar can be focused have been simplified and combined. This both helped me have a better understanding of those conditions, and made it easier to grok. I want to bring those changes over to this hook before I forget about it :)
How?
focused.
Testing Instructions for Keyboard
Test
alt+f10
shortcut in many scenarios. The block toolbar, if possible to be focused, should receive focus. If it's not able to be focused, then focus should get sent to the Document Toolbar in the top left (where the block inserter is).Screenshots or screencast