Skip to content

[dialog] scroll locking mechanism doesn't handoff well with non-base ui modal overlays #4640

Closed

Description

@ciampo

Bug report

Current behavior

When opening a base ui Dialog from another non-base ui modal overlay, it is possible that the page's scroll ends up in an unrecoverable locked state:

For example, Ariakit Menu adds a delay to its "scroll lock cleanup" to wait for animations/transitions, which causes the following bug:

  • Menu opens and sets overflow: hidden on the page
  • Menu item is clicked — Menu starts closing, but delays its scroll-lock cleanup to respect the animation
  • Dialog opens before the Menu's scroll lock cleanup has happened. It snapshots the situation (eg page is scroll-locked), then applies its own scroll lock logic, which wrongly restores page scrolling while dialog is opened
  • When the Dialog closes, it restores the previous snapshot and the page stays scoll-locked

So far, I managed to avoid the issue with a couple of workarounds:

  • trick ariakit by moving the animation on child of the popup element, so that ariakit executes scroll lock cleanup without any delays;
  • manually prevent scroll lock on the Ariakit Menu (not ideal, but seems to work);

Although I wonder if base UI could make improvemens on their side to improve scroll-lock handoff

Expected behavior

I wish base ui could coordinate cross-library scroll-lock handovers.

A few ideas:

  • Come up with a robust heuristic for better coordination/restoration. For example:
    • it should not be possible for Dialog's scroll-lock logic to enable page scroll when opening;
    • it should not be possible for Dialog's scroll-lock cleanup logic to scroll-lock the page (ie add overflow: hidden) when closing
  • expose a pluggable scroll-lock manager and/or explicit interop hooks

Reproducible example

https://stackblitz.com/edit/vitejs-vite-altbnksf?file=src%2FApp.tsx,src%2Findex.css

Kapture.2026-04-17.at.10.32.51.mp4

Base UI version

1.4

Which browser are you using?

Chrome

Which OS are you using?

Mac OS

Which assistive tech are you using (if applicable)?

N/A

Additional context

N/A

Activity

  1. added
    type: bugIt doesn't behave as expected.
    and removed on Apr 22, 2026
  2. changed the title [-][Dialog] scroll locking mechanism doesn't handoff well with non-base ui modal overlays[/-] [+][dialog] scroll locking mechanism doesn't handoff well with non-base ui modal overlays[/+] on May 8, 2026
  3. maiconcarraro commented on Jul 16, 2026

    @maiconcarraro

    this issue also happens when using silk-hq, once you close their drawer and immediately open the base-ui dialog the scroll lock becomes inverted: scrollable while dialog opened, hidden once closed.

  4. github-actions commented on Jul 19, 2026

    @github-actions

    This fix will be available in the next npm release of Base UI.

    In the meantime, you can try it out on our Canary release channel:

    npm i https://pkg.pr.new/@base-ui/react@4665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: dialogChanges related to the dialog component.type: bugIt doesn't behave as expected.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions