base-ui
base-ui copied to clipboard
[dialogs] Add iOS scroll lock elements
- [x] I have followed (at least) the PR section of the contributing guide.
Closes #1893
This solution seems to be robust in that it doesn't break input focus slide/have glitch issues with animations.
Drawbacks
- Three-four extra wrapper elements are required just to get the behavior to work. I added
disableScrollLockElementsas a way to customize them - Trying to style
<Dialog.Viewport>as a flex container for<Dialog.Popup>doesn't work because of the nesting, breaking expectations
Note that for Popover it doesn't solve the use case listed here #3100, they'd have to specify these elements manually. We could document this? <Popover.Viewport> is also conceptually different from <Dialog.Viewport> (cc: @colmtuite)
Alternatives
- Document "Locking scroll on iOS" as a separate section
- Create a separate component on iOS called
<ScrollLock>solely for the docs (copy-pasteable) so the users can edit the elements and see that<Dialog.Viewport>cannot be a flex container for<Dialog.Popup>. Reveals how to solve the Popover use case in #3100 as well. - Re-adopt usePreventScroll from RA which seems to have fixed most related issues
pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/react@3183
pnpm add https://pkg.pr.new/mui/base-ui/@base-ui-components/utils@3183
commit: 664ef97
Bundle size report
| Bundle | Parsed size | Gzip size |
|---|---|---|
| @base-ui-components/react | 🔺+401B(+0.10%) | 🔺+137B(+0.11%) |
Check out the code infra dashboard for more information about this PR.
Deploy Preview for base-ui ready!
| Name | Link |
|---|---|
| Latest commit | 3c48647c08162398624df0a27be807c88238d80b |
| Latest deploy log | https://app.netlify.com/projects/base-ui/deploys/69129a0ff4f2550008ed04f7 |
| Deploy Preview | https://deploy-preview-3183--base-ui.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
Deploy Preview for base-ui ready!
| Name | Link |
|---|---|
| Latest commit | 664ef9718f045ffccebc30a2064e23775a75419b |
| Latest deploy log | https://app.netlify.com/projects/base-ui/deploys/6912a34cf2d16600078e3f58 |
| Deploy Preview | https://deploy-preview-3183--base-ui.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.