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

[dialogs] Add iOS scroll lock elements

Open atomiks opened this issue 1 month ago • 4 comments

Closes #1893

This solution seems to be robust in that it doesn't break input focus slide/have glitch issues with animations.

Drawbacks

  1. Three-four extra wrapper elements are required just to get the behavior to work. I added disableScrollLockElements as a way to customize them
  2. 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

  1. Document "Locking scroll on iOS" as a separate section
  2. 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.
  3. Re-adopt usePreventScroll from RA which seems to have fixed most related issues

atomiks avatar Nov 11 '25 02:11 atomiks

vite-css-base-ui-example

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

pkg-pr-new[bot] avatar Nov 11 '25 02:11 pkg-pr-new[bot]

Bundle size report

Bundle Parsed size Gzip size
@base-ui-components/react 🔺+401B(+0.10%) 🔺+137B(+0.11%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

mui-bot avatar Nov 11 '25 02:11 mui-bot

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Nov 11 '25 02:11 netlify[bot]

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Nov 11 '25 02:11 netlify[bot]