Repository navigation
Conversation
…e to the focused field's container Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMkda2DXoWdE6gq1RR8
size-limit report 📦
|
…he user can't scroll, with or without a modal Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TKGZMkda2DXoWdE6gq1RR8
This branch has not been 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.
Summary
On iOS, when a field is focused near the end of a scroll container that can't scroll it above the keyboard, Safari pans the whole page instead. On a page the user can't scroll, nothing can pan it back while the keyboard is open, so the top of the page, or of an open modal, stays off screen. A page can't be scrolled in two cases:
ModalorOverlayis open. Since fix(scroll lock, modal): leave revealing the focused field above the iOS keyboard to Safari #729 this affects every modal.overflow: hiddenon the document, an app-shell layout like Untap's. This happens without any modal open.This PR handles both automatically. It doesn't take over anything Safari does. It waits for Safari to finish, then moves the pan into the focused field's scroll container (
packages/utilities/src/scroll/keyboardPan.ts):focusin, touch end or keyboard change, if the keyboard is open and the page has moved from its resting position, the handoff runs.padding-bottomwhile the keyboard is open. If the container grows with the padding instead of gaining room, the padding is dropped again.Reshapedprovider on iOS (handOverIOSKeyboardPan, exported from@reshaped/utilities/internal), andlockSafariScrollfor anyone usinglockScrollwithout the provider. Both share a single counted instance, which stops when the last one releases it.What's different from the attempts that were rolled back
mousedown, with an off-screen geometry override, and placed the caretscrollevent, including while Safari was still panningCompared with Base UI
useScrollLock(Dialog, Drawer) on iOS only sets overflow, the same as Reshaped since fix(scroll lock, modal): leave revealing the focused field above the iOS keyboard to Safari #729. Its comment says the iOS keyboard behaviour "must be researched extensively" first. So a Base UIDialoghas the same problem.Drawer.VirtualKeyboardProvider, for bottom sheets with form fields. It takes over taps ontouchend, focuses with the same off-screen transform andpreventScrolltrick as fix(scroll lock): keep Safari from panning the locked page for the on-screen keyboard #727, and preempts the keyboard's previous/next field arrows onfocusout. It pins the window scroll, adds bottom padding to the drawer's scroll body, and re-aligns over several frames and timed passes.Related Issue
Untap: with the page or a modal scrolled down and a field focused, the top can't be scrolled back to while the keyboard is open. Untap's own fix for its page is reshaped-ui/untap#202. Once this ships in a canary, that hook isn't needed.
Screenshots / Recordings
None. This only shows on an iOS device with the on-screen keyboard.
Notes for Reviewers
Not checked on an iPhone. This assumes Safari reports the pan in
window.scrollYand thatwindow.scrollTomoves it back, which the removedkeyboardPanand Base UI's provider both rely on. Worth trying:body { overflow: hidden }, content scrolling in a container) scrolled to its end;The one visible change: Safari pans as before, then about 200ms after it stops, the frame (modal or page header) slides back into place while the focused field stays put.
Not covered: a short center modal whose content fits has no scroll container to hand the pan to, so it stays the way it is today.
The provider now starts a global listener set on iOS: window and visual viewport scroll,
focusin, and touch start/end/cancel, all passive. Nothing runs on other platforms.Tests:
keyboardPan.test.ts(8 tests):The provider's iOS check isn't covered, because the tests run in desktop Chromium. Also passing: utilities
src/scrollandsrc/viewport; browser tests for Reshaped, Modal, Overlay and the hooks;tscfor both packages; lint and format.🤖 Generated with Claude Code
https://claude.ai/code/session_01TKGZMkda2DXoWdE6gq1RR8