8000 Fix scrollbar-induced layout shift by danielchalmers · Pull Request #11363 · MudBlazor/MudBlazor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix scrollbar-induced layout shift #11363

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

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

danielchalmers
Copy link
Member

Description

Resolves #9056 and fixes the page "dancing" by using native CSS properties to handle the scrollbar gutters which are now widely supported.

How Has This Been Tested?

visually

Tested on Edge and FireFox.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)
Video3.mp4

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@danielchalmers danielchalmers requested a review from Garderoben May 19, 2025 00:28
@github-actions github-actions bot added bug Something doesn't work as intended PR: needs review labels May 19, 2025
@danielchalmers
Copy link
Member Author

@versile2 Do you think this will break your recent changes?

@versile2
Copy link
Contributor

if it had the latest changes no.

@ScarletKuro
Copy link
Member

Your branch is not up to date.

Copy link
codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.12%. Comparing base (673f6f7) to head (8611f65).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11363   +/-   ##
=======================================
  Coverage   91.12%   91.12%           
=======================================
  Files         465      465           
  Lines       14409    14409           
  Branches     2788     2788           
=======================================
  Hits        13130    13130           
  Misses        641      641           
  Partials      638      638           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes manual scrollbar padding logic in JS/SCSS and leverages the native scrollbar-gutter CSS property to fix page “dancing” when scrollbars appear.

  • JS: Always apply the lock class, removing custom padding/no-padding logic
  • SCSS: Simplify .scroll-locked to only hide overflow
  • ThemeProvider: Inject html { scrollbar-gutter: stable; } into generated styles

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/MudBlazor/TScripts/mudScrollManager.js Remove JS-based scrollbar padding logic; always add/remove lock class
src/MudBlazor/Styles/layout/_scroll.scss Simplify .scroll-locked to only overflow: hidden;
src/MudBlazor/Components/ThemeProvider/MudThemeProvider.razor.cs Add native scrollbar-gutter: stable; CSS rule
Comments suppressed due to low confidence (2)

src/MudBlazor/TScripts/mudScrollManager.js:60

  • The updated locking logic isn’t covered by existing tests; consider adding unit tests to verify behavior when CSS 'scrollbar-gutter' is unsupported and ensure the lock count logic works as expected.
lockScroll(selector, lockclass) {

src/MudBlazor/TScripts/mudScrollManager.js:63

  • Consider retaining the fallback logic or adding a feature-detection check for CSS 'scrollbar-gutter' support to prevent layout shifts in browsers that don't support the property.
element.classList.add(lockclass);

@versile2
Copy link
Contributor

It has no visible effect on Firefox, and Firefox doesn't dance, but fixes both Chrome and Edge from dancing. It does have a display on Dialogs and does not interfere with my PR just aims to ensure the class isn't added/removed unnecessarily.

Old way removes the scrollbar
Screenshot 2025-05-19 131200

With Stable Gutters, keeps but unable to use the scrollbar
Screenshot 2025-05-19 131212

@danielchalmers danielchalmers marked this pull request as draft May 19, 2025 20:01
@danielchalmers danielchalmers changed the title Let CSS handle scrollbar offset Fix padding reserved for scrollbar on WebKit browsers May 19, 2025
@danielchalmers danielchalmers changed the title Fix padding reserved for scrollbar on WebKit browsers Fix padding reserved for scrollbar May 26, 2025
Copy link

@danielchalmers danielchalmers changed the title Fix padding reserved for scrollbar Fix scrollbar-induced layout shift Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something doesn't work as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve scrollbar alignment across browsers by removing hardcoded padding
3 participants
0