components/Menu: Restore Modal focus return when menu items close - #81164
Conversation
|
Size Change: +266 B (0%) Total Size: 7.65 MB 📦 View Changed
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
713d598 to
ed6a4b3
Compare
|
I will soon start the release process for 7.1 RC1. Let's consider releasing this PR for RC2 if possible. |
mirka
left a comment
There was a problem hiding this comment.
I'm doing the test instructions in Storybook, and I noticed that the scroll lock only works when the "WordPress" styles are injected (common.css). It doesn't work with "font only". I think maybe a overflow: hidden is missing on body?
ed6a4b3 to
3eb5247
Compare
I believe that was already the case for I also improved the JSDocs for the This PR should hopefully be ready for a final review round. |
|
There was a conflict while trying to cherry-pick the commit to the wp/7.1 branch. Please resolve the conflict manually and create a PR to the wp/7.1 branch. PRs to wp/7.1 are similar to PRs to trunk, but you should base your PR on the wp/7.1 branch instead of trunk. |
|
I submitted a PR because the cherry-pick failed. The conflicting part is unrelated to the current logic change, so I intend to merge it after smoke testing if there are no issues. #81446 |
|
There was a conflict while trying to cherry-pick the commit to the wp/7.1 branch. Please resolve the conflict manually and create a PR to the wp/7.1 branch. PRs to wp/7.1 are similar to PRs to trunk, but you should base your PR on the wp/7.1 branch instead of trunk. |
…1164) * Menu: Restore focus handoff when items close * Menu: Preserve default modal dismissal coverage * Menu: Preserve hideOnClick behavior during focus handoff * Menu: Add focus handoff changelog * Menu: Cover closing and keep-open Modal stories * Menu: Simplify Modal regression coverage * Modal: Add default scroll lock styles * Menu: Follow current import conventions --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: yashjawale <yashjawale@git.wordpress.org>
…1164) * Menu: Restore focus handoff when items close * Menu: Preserve default modal dismissal coverage * Menu: Preserve hideOnClick behavior during focus handoff * Menu: Add focus handoff changelog * Menu: Cover closing and keep-open Modal stories * Menu: Simplify Modal regression coverage * Modal: Add default scroll lock styles * Menu: Follow current import conventions --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: yashjawale <yashjawale@git.wordpress.org>
What?
Closes #80734.
Restores focus return when a legacy
Modalopens from a closing Menu. It also makes the default Modal scroll lock work without WordPresscommon.css.The existing
hideOnClickbehavior is unchanged.Why?
#77460 made menus unmount immediately to preserve the menu-to-Modal scroll-lock handoff. The focused item now disappeared before Modal captured its focus-return target, so focus returned to the page instead of the root menu button.
How?
When an item is about to close its menu and focus is still inside it, focus moves to the root menu button before Ariakit unmounts the menu. The immediate teardown and Ariakit activation safeguards remain unchanged.
Modal now includes the default
body.modal-open { overflow: hidden; }style. CustombodyOpenClassNamevalues still require their own scroll-lock CSS.Testing Instructions
Testing Instructions for Keyboard
Repeat using Enter to select Open modal.
Screenshots or screencast
Kapture.2026-08-04.at.17.41.19.mp4
Kapture.2026-08-04.at.17.47.06.mp4
Use of AI Tools
Codex was used to inspect the regression history and installed source, implement the focused change and tests, and run verification. The resulting diff and test evidence were reviewed locally.