Skip to content
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

fix(cdk/overlay): scroll was blocked when zoomed out even if scrolling wasn't an option #30548

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

szoboszlaypali
Copy link

@szoboszlaypali szoboszlaypali commented Feb 25, 2025

Fixes that an unnecessary disabled scroll bar was added when zoomed out during opening dialogs.

Fixes #25054.

When you zoom out using the browser (not the style.zoom css), dimensions can become non-whole numbers. window.innerHeight/innerWidth uses Math.floor to round these dimensions, while body.scrollHeight/scrollWidth uses Math.round (at least that's what I assume), so in case you zoom out and your browser shows that your width is 1000.66px for example, the previous implementation returned false positives if there were no scroll bars, as the scrollWidth was 1001px while innerWidth was only 1000.

Another thing I've ran into is using the style.zoom css api, while the innerHeight and innerWidth remains unchanged during zoom, working as intended body.scrollWidth can outgrow window.innerWidth without a scroll bar appearing (easily testable with the Google home page).

Relying on the root documentElement's scrollWidth and scrollHeight seems to fix both cases.

…g wasn't an option

Fixes that an unnecessary disabled scroll bar was added when zoomed out during opening dialogs.

Fixes angular#25054.
@szoboszlaypali szoboszlaypali requested a review from a team as a code owner February 25, 2025 21:51
@szoboszlaypali szoboszlaypali requested review from crisbeto and mmalerba and removed request for a team February 25, 2025 21:51
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants