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

Update modal.css #2956

Merged
merged 2 commits into from
Apr 4, 2024
Merged

Update modal.css #2956

merged 2 commits into from
Apr 4, 2024

Conversation

vadimkiryanov
Copy link
Contributor

When opening a modal window, the scrollbar disappears, but the content shifts

This padding automatically shifts the content to the left so that the user does not notice the content moving when the scrollbar disappears

Padding is equal to the standard scrollbar width

When opening a modal window, the scrollbar disappears, but the content shifts

This padding automatically shifts the content to the left so that the user does not notice the content moving when the scrollbar disappears

Padding is equal to the standard scrollbar width
@saadeghi
Copy link
Owner

saadeghi commented Apr 4, 2024

Can you use scrollbar-gutter instead?

Padding will be applied to all operating systems including iOS, Android, MacOS where scrollbars don't take any space.

We would only need that spacing in operating systems which dedicate a 15px space for scrollbars. Also it may not be always 15px based on user settings. CSS scrollbar-gutter takes care of the size as well.

Added scrollbar-gutter
@vadimkiryanov
Copy link
Contributor Author

Can you use scrollbar-gutter instead?

Padding will be applied to all operating systems including iOS, Android, MacOS where scrollbars don't take any space.

We would only need that spacing in operating systems which dedicate a 15px space for scrollbars. Also it may not be always 15px based on user settings. CSS scrollbar-gutter takes care of the size as well.

Yeah, you are absolutely right! 👍

@saadeghi saadeghi merged commit f05e854 into saadeghi:master Apr 4, 2024
@TreyRuffy
Copy link
Contributor

It looks like this now shifts the content to the left on pages with no scrollbar

@ShahadatAnik
Copy link

If i don't want to show the scrollbar, what should I do?

@gremo
Copy link

gremo commented Apr 8, 2024

I experience the same problem as @TreyRuffy

I think it's a bug introduced with this change. No page is shifted to the left! @saadeghi

@ShahadatAnik

/* app.css */
@layer base {
  :root:has(:is(.modal-open, .modal:target, .modal-toggle:checked + .modal, .modal[open])) {
    scrollbar-gutter: revert !important;
  }
}

@thenetwrx
Copy link

This gave me a headache! I don't see the benefit for this behavior by default. But thanks @gremo ❤️

@nbran
Copy link

nbran commented Apr 19, 2024

Having the Modal component change the styling of the root element on the assumption that a scrollbar is present is problematic and bound to result in unwanted behavior.

@nbran nbran mentioned this pull request Apr 20, 2024
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.

None yet

7 participants