Repository navigation
fix(scraps): Make modal scroll locking hold up on mobile - #132288
Draft
sentry-junior[bot] wants to merge 1 commit into
Draft
sentry-junior[bot] wants to merge 1 commit into
sentry-junior[bot] wants to merge 1 commit into
Conversation
useScrollLock could create a second Lock for document.body after an idle hook unmounted, so the mobile nav and the modal saved and restored body styles independently. The page could unlock under an open modal or stay fixed after everything closed. Locks now live for the page, scroll restores in the same task, and the scrollbar width comes from layout widths instead of innerWidth, which tracks pinch zoom on iOS. The modal host now locks, hides the background, and restores focus only when it opens or closes, so a modal that replaces another keeps the page position. Its scroll container follows the visual viewport so the on-screen keyboard does not cover the footer, and openModal blurs a focused text field first. A passive drawer that replaces a locking drawer now unlocks the page, and the framework suggestion modal caps its heights to the dynamic viewport. Refs #132108 Co-Authored-By: nate <7118177+natemoo-re@users.noreply.github.com>
Contributor
Story previewsPreview the stories changed in this PR on the Vercel deployment:
Preview deployment: https://sentry-igdfd0bf1.sentry.dev |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes the shared scroll lock and modal host behind the "broken or janky modals on mobile" reports. It's the follow-up to #132285, which fixes modals with no height on Safari and iOS before 18.4. The two PRs are independent.
useScrollLockLockfrom the map. Hooks that stay mounted (GlobalModal,GlobalDrawer) kept the old instance, and the next hook to mount (MobileNavigation,ReorderableList) created a second one. Both saved and restoredbodystyles on their own. Opening a modal over the mobile nav and then closing both unlocked the page while the modal was open, and leftbodystuck onposition: fixedafterwards. Locks now stay in aWeakMap.scrollYis 0. With therequestAnimationFramerestore, an acquire right after a release (one modal replacing another, or a drawer closing as a modal opens) read that 0, pinned the page at the top, and lost the position on close.scrollToforces layout with the restored styles, so it works synchronously.documentElement.clientWidthgained by pinning the body.innerWidthfollows the pinch-zoomed visual viewport on iOS, so the old formula could produce negative or very large padding and--scrollbar-size.Modal host
visualViewport. It usesoffsetTopandheight. The on-screen keyboard and pinch zoom only shrink the visual viewport, which could leave the footer (Confirm, Delete) under the keyboard while the body was pinned. The container also getsoverscroll-behavior: contain.openModalblurs a focused text field before the page locks. This is what fix(onboarding): Keep the framework prompt usable on mobile #132109 does for one prompt, applied to every modal.preventScroll.Other
80vhbecomes80dvh, and the 550px and 631px minimum heights are capped at80dvh, so the dialog fits a phone with its toolbars showing.Everything used is within our browserslist floor (iOS 18.0, Safari 17.0):
dvh(Safari 15.4),overscroll-behavior(16),visualViewport(13).Open before review: the visual-viewport sizing and the keyboard handling need a real iOS and Android device. Chromium emulation doesn't reproduce how WebKit handles the keyboard. Use the framework suggestion modal story from #132201 with and without the keyboard open, plus a modal with an input near its footer.
Refs #132108
via @natemoo-re.
--
View Session [Sentry]