-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 focus from zoom inserter #66256
Fix focus from zoom inserter #66256
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
165d2e7
to
05ea598
Compare
Size Change: +29 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
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.
Works well for me! I think this is good as a hotfix to 6.7. I'm not sure why we shouldn't fix it also on trunk too? Perhaps we'll need to backport this to trunk afterwards.
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 code works as described and I appreciate the logic for needing to move the focus.
What I'm not sure on is if this is expected behaviour for keyboard users?
I assume the optimal fix would be to move focus when the ENTER
is pressed? But because the inserter is already opened we cannot do that.
I explore trying to create a command to re-focus the inserter search but I didn't have any success. I think it's a wider issue of us needing a means of focusing specific parts of the editor UI programmatically.
As I don't have enough expertise, I'd like to get some a11y reviews on this one if possible. I appreciate you do have expertise so if you advise that this approach is justifiable I would be happy enough moving forward.
@kevin940726 what do you think?
This doesn't have to land in RC1. It fixes a bug introduced during 6.7 cycle so we can legitimately land it for RC2 when we're confident it's the right fix. |
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.
For a bug fix to backport this looks legit. What can we do to iterate and not rely on this? I wonder if we should allow imperative focus management in an abstracted way like focusLeftSidebar() and have the editor only then manage the dom access.
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.
I'm not sure why we shouldn't fix it also on trunk too?
This isn't the right fix for trunk. A "proper" fix would require passing around refs which isn't a trivial change. So for 6.7 this is good, but the bug should be fixed properly on trunk instead of just backporting this.
Ok folks. There are enough 👍 here that this is a good enough patch for 6.7. I agree with the need for a more comprehensive fix in |
What?
If the inserter (block library) is already open, clicking the Add pattern button from the canvas does not move focus.
Why?
The block inserter receives focus on mount, but if it's already mounted, there isn't a way to move focus to it.
How?
This adds a
document.querySelector( '[aria-label="Block Library"]' )?.focus()
in the Add patternonClick
to send focus to the inserter if it is already open.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Screen.Recording.2024-10-18.at.1.12.39.PM.mov