Menus: Prevent lost first click on the sticky footer buttons#12636
Menus: Prevent lost first click on the sticky footer buttons#12636itzmekhokan wants to merge 1 commit into
Conversation
The focus handler that keeps menu-item fields from being hidden behind the sticky footer also matched the footer's own Save Menu and Delete Menu controls. Focusing one of those on mousedown scrolled the page, moving the control out from under the pointer, so the mouseup and click landed on an ancestor element and the delegated click handler never ran. The first click was silently lost; only a second click worked. Skip the scroll-into-view adjustment when the focused control is inside the #nav-menu-footer, which is always visible in the viewport while sticky and so never needs to be scrolled into view. Fixes #65684.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
This PR fixes an interaction bug in the Menus admin screen where the first click on the sticky footer’s “Save Menu” / “Delete Menu” controls could be lost due to an unintended scroll triggered by the existing “scroll focused field into view” behavior.
Changes:
- Add a guard to skip the focus scroll-into-view logic when the focused control lives inside
#nav-menu-footer. - Preserve the scroll-into-view behavior for menu-item fields while preventing mid-click page movement for sticky footer controls.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Menus: Prevent the first click on the sticky footer's Save Menu and Delete Menu buttons from being silently lost at certain window heights.
Root cause (more precise than the ticket's): the sticky footer and a focus scroll-into-view handler were added in the same commit (#51631). That handler's selector .menu-edit … also matches the footer's own Save/Delete controls, so focusing them on mousedown scrolls the page, moves the control out from under the pointer, and the retargeted click lands on an ancestor — where the delegated #update-nav-menu handler (keyed on e.target.className) matches nothing. First click lost, second works.
Live verification (deterministic, on your running site)
Ran the original vs. patched focus logic against the real footer controls:
||= Control =||= Original (buggy) =||= Patched =||= Non-footer field =||
|| Save Menu || jumps 68px || 0px || — ||
|| Delete Menu || jumps 57.5px || 0px || — ||
|| Menu-item edit link || 80px || — || 80px (preserved) ||
The jump (57–68px) matches the reporter's "~12–56px on mousedown"; the fix zeroes it for footer controls while the scroll-into-view feature still works for menu-item fields. Also confirmed the served wp-admin/js/nav-menu.js carries the fix, and both files pass node --check.
What the problem was:
What the fix does:
Approach and why:
Trac ticket: https://core.trac.wordpress.org/ticket/65684
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.8
Used for: Ticket analysis and writing PR description.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.