Repository navigation
DropdownMenu: Match initial focus to the opening interaction - #85486
Conversation
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +227 B (0%) Total Size: 8.56 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Undo restores the post selection when another synced entity is loaded in
|
|
I think this looks like a fine solution. From what I could test with a quick spin on playground it works as expected. It so happens that I'd made a branch doing this same thing in a different way but didn't get around to making a PR for it. Seeing this spurred me put it up as #85531. I wanted to suggest it as an alternative yet I see this is meant for a backport so I expect that might not be conducive for either time or scope constraints to consider it now. Even if that's so, it might be worth a look later since I think its basis of extending |
|
Love this! It's been a pet peeve for a long time :D |
dd857a7 to
59cc7b0
Compare
|
I'm going to merge this. I plan to release Gutenberg 23.4 stable later today. |
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
…#85826) Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> (cherry picked from commit c4085c3) --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
|
Manually backported in #85826 |
Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
…ss#85486) Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: stokesman <presstoke@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Split from #84583. This PR targets
trunkindependently.What?
Focus the DropdownMenu container when opening with a pointer. Keyboard and virtual activation keep first-item focus, and arrow keys can enter a pointer-opened menu.
Why?
Pointer opening should not highlight the first item before the pointer reaches an item.
How?
Choose the default Popover focus mode from the opening event and move pointer focus to the semantic menu. Reset that choice on close. Explicit
focusOnMountvalues and consumer focus handlers retain precedence. Container entry is limited to menu arrow keys, preserving native Tab and Shift+Tab navigation.The two existing editor E2E flows now enter the pointer-opened menu with ArrowDown before checking first-item focus. No test files or test bodies were added.
Testing Instructions
popoverProps.focusOnMountsettings and consumer focus handlers. A later controlled opening should use the default first-item focus.Testing Instructions for Keyboard
TabbableContainer cycle={false}. Shift+Tab should leave it; Tab should enter its first tab stop.Verification and limits
Existing dropdown, Popover, and navigation tests passed, along with typecheck, lint, and the production build. CLI browser checks cover pointer and keyboard opening, arrow entry, focus return, explicit focus settings, custom focus targets, controlled reopening, and Tab navigation. A synthetic empty-pointer-type click with nonzero detail checks virtual activation handling; actual screen readers and real touch hardware remain untested.
The two edited editor E2E flows could not run locally because Docker exhausted its default address pools while creating the test environment. Their pointer-opened menus now explicitly receive ArrowDown before first-item assertions, including the locked-block case. CI still needs to verify the final E2E update.
Screenshots or screencast
Standalone DropdownMenu Default, basic global CSS, 520 × 330.
Use of AI Tools
Implemented, reviewed, and verified with Codex. I reviewed the changes and remain responsible for them.