-
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
Focus loss when unlocking a block from the block toolbar Unlock button #51447
Comments
I can think of a few options to solve this issue. Ideally, toolbar buttons should not be rendered dynamically. The block toolbar is an ARIA toolbar pattern implementation, where focus management is expected to have very specific behaviors. Also, the modal dialog itself expects a DOM element where move focus to when it closes. I would say the root problem here is in the design itself of this feature. The design didn't take into consideration how to implement a correct keyboard interaction. That said:
Pinging @ciampo and @mirka 👋 because of your experrtise about components. |
I believe that there's more than one conditional toolbar button being rendered:
As you mentioned, the simplest solution would be to always show the lock. Although I'm not sure that would be feasible because it would imply showing an extra button for every "lockable" block, and I'm not sure we want / can do that (it's out of my area). Always in the group of simple solutions, we could remove the "unlock" button from the toolbar altogether, but again — not my call, really. I wonder if @jasmussen can chime in on this aspect. As you suggest, we could also look into the |
I understand the situation but would hope we can find creative solutions other than always showing the lock in the block toolbar. For most blocks, there won't be room to have it there, and it would also give undue prominence to the feature. |
Tentative approach in #51666 |
The conditional button rendering needs to go away. We need to make a choice where lock/unlock should go. Either in the toolbar or in the options submenu, but not both depending on a given state. @jasmussen Please work on the design to maybe always keep this option in the options submenu. This pattern that is constant through the editor of appearing and disappearing buttons has to stop for the better good of all users. Do keep in mind that React does try to save focus for us but sometimes when the UI changes so much, this being one of those times, we have to add work-arounds in code to manage focus. We shouldn't need to do this much work to manage focus. This might mean that the design itself is inaccessible. Thanks. |
I'd second @alexstine about the fact the root problem here is that design didn't take into account keyboard accessibility since the beginning. I'd love to see more awareness and knowledge that keyboard must be taken into account since the design phase. |
That prevents a total focus loss, but to follow expected patterns, it should return focus to the button in the toolbar that opened it (the lock button). #57229 should be a better fix for this issue, as it leaves the lock button in the toolbar until the toolbar is unmounted. |
Description
Focus losses should be avoided at all costs, as they're one of the most terrible experiences for keyboard users.
When a modal dialog closes, focus is expected to be moved back to the control that opened the modal dialog. In the editor, this is what
withFocusReturn
is meant for.However, when the control that opened the modal dialog gets removed from the DOM or gets hidden with CSS, there's no place where focus can be moved back to and focus is lost. This is hte case when unlocking a block from the 'Unlock' button in the block toolbar.
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: