-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Block editor/packages/block-editor/packages/block-editor[Package] Components/packages/components/packages/components[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
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
- Edit a post and lock a block e.g. a paragraph block.
- Click on the paragraph content and from now on use the keyboard.
- Press Shift + Tab to move focus to the block toolbar.
- Use the Right arrow key to go to the Options ellipsis button. Press Enter to open the Options menu.
- Use the Down arrow key to move focus to the 'Lock' button and press Enter.
- The Lock block modal dialog opens.
- Lock the block, move focus to the Apply button and press Enter.
- The modal dialog closes.
- Observe focus is moved back to the button in the menu that is now named 'Unlock'.
- Press Enter to open the Lock block modal dialog again.
- Unlock the button, move focus to the Apply button and press Enter.
- Observe focus is moved back to the button in the menu that is now named 'Lock'. So far, so good: focus managed correctly.
- Lock the block again.
- Click on the paragraph content and from now on use the keyboard.
- Press Shift + Tab to move focus to the block toolbar.
- Use the Right arrow key to go to the Unlock button, the one placed after the block switcher button:
- Press Enter. The lock block modal dialog opens. Unlock the block and press Apply.
- The modal dialog closes.
- The 'Unlock' button in the block toolbar gets removed. There's no place where to move focus back to.
- Press the Tab key.
- Observe that focus is lost and the tab sequence starts from scratch from the document root: focus goes to the Site logo button at the beginning of the editor:
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
Metadata
Metadata
Labels
[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Block editor/packages/block-editor/packages/block-editor[Package] Components/packages/components/packages/components[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended