Skip to content

fix(dialog): scrollbar Flash on opening #5121 #5802

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bipedal-eel
Copy link

This prevents the scrollbar from flashing (Chromium) as mentionend in #5121

@@ -173,7 +173,7 @@
// space from appearing on platforms that reserve scrollbar space.
// Note: we only scroll vertically. Horizontal scrolling should be handled
// by the content.
overflow-y: scroll;
overflow-y: auto;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I understand correctly, this works by not forcing the scrollbar to show (auto vs scroll) if we detect overflowing content in JS and add the .scrollable class?

What is the advantage to this solution as opposed to addressing the issue in JS that results in an inaccurate toggling of the .scrollable class?

For example, toggling the class after open animations have settled as suggested in #5121 (comment).

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you understand correctly.

I suppose ive always been drilled on doing css over js but I can see your point, especially since there are open and close methods already.

Will do this in js 👍

@@ -185,6 +185,7 @@
font-weight: map.get($tokens, 'supporting-text-weight');
height: min-content; // Needed for Safari
position: relative;
overflow-y: clip; // Needed for .scrollable .scroller
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is overflow-y: clip vs the default overflow-y: visible needed for the scroller?

Copy link
Author

Choose a reason for hiding this comment

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

Not too sure on that actually... .content overflows when scroller is set to auto, so this prevents that. This would make more sense in a .scrollable > .content but as mentioned above ill go do this in js

@bipedal-eel
Copy link
Author

bipedal-eel commented May 13, 2025

i have found the underlying issue:
image

the screenshot is console logs in render():

protected override render() {
    console.log("isOpen", this.isOpen)
    console.log("open", this.open)
    console.log("opening", this.isOpening)
    const scrollable =
      this.open && !(this.isAtScrollTop && this.isAtScrollBottom);
    console.log(scrollable)
// ...
}

Now, scrollable is only set when !isOpening.

const scrollable =
      !this.isOpening && this.open && !(this.isAtScrollTop && this.isAtScrollBottom);

I tested this a bit and as far as i can tell, this does not break anything.

If it does, an alternative soloution would be the comment you mentioned or setAttribute("opening", "") and doing:

.scrollable .scroller:not([opening]) {
  overflow-y: scroll;
}

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

Successfully merging this pull request may close these issues.

2 participants