List View and Block Library regions are not always present in the DOM
Description
Mentioned to me by @alexstine, and I couldn't find an existing issue, so reporting it now.
The List View and Block Library regions are not always present in the DOM. This makes accessing them via the navigate regions shortcut difficult or impossible.
It'd be good to make them work more consistently, like the 'Editor Settings' region, where the container DOM element is always present. Possibly there should be a way to open the sidebars when they're closed but focus lands within the region, similar to the way the 'Publish Panel' can be opened in the post editor.
From a tech debt point of view, it might be worth consolidating these separate regions into one if a good semantic name can be given to it.
Step-by-step reproduction instructions
- Open one of the editors
- Use the navigate region shortcut (Ctrl+Alt+N or Ctrl+`)
- Cycle through the regions and notice the List View or Block Library regions are never announced.
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
I was able to reproduce this on trunk (c6a80c4bbfa) in Chrome, in the post editor.
Steps
- Open a new post with the inserter (Block Library) closed.
- Put focus on the "Settings" button in the header.
- Press `Ctrl+`` (the shortcut for moving to the next editor region) repeatedly.
Result: the focus cycle goes through the editor content, Settings, Publish and Footer regions, but never lands on the Block Library region. That region only exists in the DOM while the panel is open, because interface-skeleton/index.tsx renders it only when secondarySidebar has content.
What I tried: I changed the skeleton to always render the region (!! secondarySidebar && became always true, and { secondarySidebar } became { secondarySidebar || null }). The region is then part of the cycle, but when the panel is closed it is empty and has zero width, with no focusable children. Pressing the shortcut puts focus on something the user can't see or use. So making it "always present" is not enough by itself.
Question for maintainers: which behaviour do we want when the shortcut reaches this region while it is closed?
- Skip it while it is closed, which is today's behaviour. Then the issue is closed as intended, or the title is narrowed.
- Keep it in the cycle and open the panel on focus. This needs extra logic and a decision on which panel to open (inserter or List View).
- Keep it in the cycle as an always-present landmark, with something visible and focusable in it.
I only tested the inserter case, so I haven't confirmed that List View behaves the same way. I haven't opened a PR, as I'd like to know the preferred direction first.