-
Notifications
You must be signed in to change notification settings - Fork 12
Fix page jitter by compensating for scrollbar width #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: ruibaby <[email protected]>
Co-authored-by: ruibaby <[email protected]>
Co-authored-by: ruibaby <[email protected]>
|
@copilot I don’t think it’s necessary to add a parameter to control lockScroll. Could we instead address the offset issue caused by hiding the body scrollbar when the search modal is open? |
Co-authored-by: ruibaby <[email protected]>
You're absolutely right! I've removed the The solution calculates the scrollbar width and adds equivalent padding to the body when hiding overflow, preventing any layout shift. This is the standard approach used by VitePress and other modern UI libraries. Changes in commit
Visual proof: The page content now stays perfectly aligned with no jitter! |
ruibaby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ruibaby The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes the page jitter/shake issue when the search modal opens by compensating for the scrollbar width, following the same approach as VitePress.
Problem
When the search modal opens, hiding the body scrollbar caused the page content to shift to the right, creating a jarring visual effect.
Solution
Instead of adding a configuration option, this implements the standard fix by:
window.innerWidth - document.documentElement.clientWidthpadding-rightequal to the scrollbar width when hiding body overflowThis ensures the page content stays in the exact same position when the modal opens and closes.
Changes Made
search-modal.tswillUpdatemethod to calculate and apply padding compensationindex.html) to demonstrate the fix with scrollable contentVisual Proof
Before opening modal (with scrollbar):

After opening modal (no layout shift):

✅ The page content stays perfectly aligned - no jitter or shift!
Testing
Fixes #62
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.