Repository navigation
Fix: Navigation overlay layout jitter - #77936
DarkMatter-999 wants to merge 4 commits into
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @Mathijsvdbeek. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
What?
Closes #77571
When opening the Navigation block overlay, the page applies an
overflow: hiddenrule to the<html>root, which causes the browser's vertical scrollbar to disappear. This PR dynamically adds inline padding to the<body>equal to the width of the disappearing scrollbar, preventing the background page content from jumping to the side.Why?
Currently, if a page has enough content to require a scrollbar, opening the navigation overlay causes an abrupt layout jitter ("text jump") because the viewport suddenly expands by the width of the missing scrollbar. This creates a jarring user experience.
How?
In the navigation block's interactive frontend logic (
packages/block-library/src/navigation/view.js), we intercept theopenMenuaction before thehas-modal-openclass is applied. We calculate the scrollbar width. If a scrollbar is present, we temporarily apply an equivalentpaddingLeftorpaddingRight(respectingrtlattributes) to thedocument.body.We cache any existing inline padding values before modifying them, and accurately restore them in the
closeMenuaction so we don't destructively overwrite theme or plugin-specific body paddings.Testing Instructions
100vw)Or follow the video linked in this issue comment
Screenshots or screencast
Before
navigation-overlay-jitter.mov
After
navigation-overlay-jitter-fix.mov
Use of AI Tools
Used Github Copilot(Gemini 3.1 Pro) to review the PR.