WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.48k stars 4.18k forks source link

Editor Navigation panel: Focus loss when the Actions ellipsis button is removed from the DOM #60172

Open afercia opened 7 months ago

afercia commented 7 months ago

Description

Prior accessibility feedback outlined several times that focusable elements that are meant to have / receive focus should never, ever, be removed from the DOM, or get hidden, or get fully disabled dynamically. When doing so, a keyboard focus loss is very likely triggered.

Recent changes to the Site editor navigation panel missed, once again, this important point.

For example:

This problem may occur as well in other places in the navigation panel, it's not limited to editing Templates.

Instead of removing the ellipsis button, it should be stay in the DOM and still be focusable. For this purpose, the editor uses a specific pattern: noop the button and add an aria-disabled="true" attribute.

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

Screenshot of the Clear customizations modal dialog open: notice the Navigation panel does show the ellipsis button:

Screenshot 2024-03-25 at 15 04 14

After successful clearing, the ellipsis button is removed froom the DOM:

Screenshot 2024-03-25 at 15 04 38

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

afercia commented 7 months ago

I added the Design label to the issue to bring designers attention to the fact the design of this flow is far from ideal in the first place. Controls that have focus or, like in this case, that are meant to receive focus after some action, must not be removed dynamically from the DOM (or hidden or fuly disabled).