Repository navigation
[dialog] Fix scroll lock handoff with external overlays - #4665
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,233.32 ms -17.19 ms(-1.4%) | Renders: 78 (+0) | Paint: 1,952.26 ms -34.16 ms(-1.7%)
13 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
25fd8b9 to
df56ec1
Compare
| if (isPageScrollLocked(win, html, body)) { | ||
| this.restore = this.observePageScrollUnlock(referenceElement); |
There was a problem hiding this comment.
So IIUC, we're handling the case where scroll-lock is applied by someone else before we run. Do we also need to handle the case where someone tries to apply a scroll-lock after we have already applied a scroll-lock?
There was a problem hiding this comment.
Yep, and the inverse is harder. Before we lock, we can safely detect an existing external lock and wait, but after Base UI has locked, later locks write to the same html/body style/clase attr, so there isn’t a reliable signal to tell which overflow: hidden belongs to which lib
There was a problem hiding this comment.
I've thought about this a bit more, and I think we should avoid including too much complexity in our codebase to deal with this issue. We should aim/optimize for the case where we're the sole low-level library and not try to fix every edge-case with users mix and matching libraries. We're adding complexity & bundle-size costs for everyone by doing so.
I think dealing with this edge-case is fine, but if there are more we should expose the ScrollLocker and let users integrate libraries cleanly instead of us trying to guess what happens by observing the DOM.
romgrk
left a comment
There was a problem hiding this comment.
LGTM beyond the missing comment. Maybe the names could be reworked to hasExternalScrollLock and observeExternalScrollUnlock — "external" makes it more clear what those are for, and "page" doesn't add much as the scroll lock always apply to the full page.
|
Hey @atomiks , do you plan on resuming work on this anytime soon? If not, can I help to push this PR to the finish line? |
4314152 to
3e7a58a
Compare
a966837 to
2e8fc77
Compare
2e8fc77 to
4668ab1
Compare
Fixes #4640
Base UI was treating an externally scroll-locked page as settled state, which breaks delayed handoffs from non-Base-UI overlays. If a third-party overlay clears its
htmlorbodylock afterDialogopens, the page can become scrollable under the open popup or stay locked after close.Changes
htmlorbodyscroll locks to clear before Base UI takes over its own lock.bodyandhtmlhandoffs intoDialog.