base-ui icon indicating copy to clipboard operation
base-ui copied to clipboard

[Modal] Support scrollbar-gutter

Open oliviertassinari opened this issue 1 year ago • 3 comments

Steps to reproduce

Steps:

  1. Add this CSS to the page:
html {
  scrollbar-gutter: stable;
}

and render a <Modal> component, e.g.

https://github.com/mui/material-ui/assets/3165635/45c6fba0-f34c-4b71-91c6-791bad4fa94a

Current behavior

The layout moves and the backdrop doesn't cover the whole page.

Expected behavior

Either scrollbar-gutter: auto is set as a temporary reset while the dialog is open (better) or no padding is added to the body.

Context

  • The issue is with Base UI's Modal component.
  • I wondered if this could make sense for the flesh of the CssBaseline component mui/material-ui#38507, but https://github.com/tailwindlabs/tailwindcss/pull/8234 does have a point. It's not something you want 100% of the time, it doesn't make sense with e.g. Google Maps.

TODO

  • [ ] To change the approach in mui/material-ui#40749 once this issue is solved (probably in the same PR actually)

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: scrollbar gutter

oliviertassinari avatar Jan 23 '24 00:01 oliviertassinari

@DiegoAndai I removed the Material UI v7 milestone: There is no need for a breaking change, this could be fixed tomorrow, and it's Base UI that needs to be fixed.

Also changed the [tag] to match with the GitHub label ([modal]).

oliviertassinari avatar Jan 23 '24 22:01 oliviertassinari

A side note, a similar outcome can be achieved with the overflow-y style:

html {
  overflow-y: scroll;
}

but it's not ideal, see the difference in UX (Windows):

https://github.com/mui/material-ui/assets/3165635/f73ccd36-d2e5-41b5-a859-a4dcc0ff7022

oliviertassinari avatar Jan 23 '24 23:01 oliviertassinari

Related https://frontendmasters.com/blog/scroll-locked-dialogs/

oliviertassinari avatar Feb 23 '24 16:02 oliviertassinari

Done in #604

vladmoroz avatar Sep 17 '24 15:09 vladmoroz

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

github-actions[bot] avatar Sep 17 '24 15:09 github-actions[bot]