[Drawer] Content-sized drawer is mispositioned when the virtual keyboard opens on iOS
Current behavior
When using Drawer.VirtualKeyboardProvider, a content-sized drawer is positioned incorrectly after focusing an input and opening the virtual keyboard on iOS.
The issue is reproducible with a minimal drawer containing a single input.
In Chrome on iOS:
- The drawer moves higher than necessary.
- A large empty area appears between the drawer content and the keyboard.
- Vertical scrolling becomes possible.
In Safari on iOS:
- Extra empty space appears below the drawer content.
The problem reproduces consistently, although its exact visual behavior may vary.
A related issue also occurs in the official Virtual keyboard aware drawer example:
https://base-ui.com/react/components/drawer#virtual-keyboard-aware
In the official example, the problem reproduces only in Chrome on iOS when focusing an input near the bottom of the drawer. The other inputs behave normally. The official example works correctly in Safari on the same device.
Reproduction steps
Content-sized drawer
- Open the live reproduction on a physical iPhone: https://base-ui-drawer-ios-repro.vercel.app/
- Press Open keyboard-aware drawer.
- Tap the input.
- Wait for the virtual keyboard to appear.
- Observe the position and scrollable area of the drawer.
Official documentation example
- Open the following page in Chrome on iOS: https://base-ui.com/react/components/drawer#virtual-keyboard-aware
- Open the Virtual keyboard aware drawer example.
- Focus an input near the bottom of the drawer.
- Observe that the drawer content may move outside the visible viewport.
- In some cases, the layout does not recover until another tap or until the keyboard is closed.
Expected behavior
A content-sized drawer should retain its content-based height and move only as much as necessary to remain above the virtual keyboard.
Focusing an input should not introduce:
- A large empty area between the drawer content and the keyboard.
- Additional vertical scrolling.
- Extra bottom spacing.
- A temporary or persistent shift outside the visible viewport.
Reproducible example
- Live reproduction: https://base-ui-drawer-ios-repro.vercel.app/
- Source code: https://github.com/k4dykovv/base-ui-drawer-ios-repro
- Related documentation example: https://base-ui.com/react/components/drawer#virtual-keyboard-aware
The reproduction is based on the official example, with all but one input removed and no footer. The original styles and the unmodified Drawer.VirtualKeyboardProvider are used. The drawer has height: auto and sizes itself to its content.
Base UI version
1.8.0
Browser and OS
Device: Physical iPhone
OS: iOS 26.4
Chrome: 153.0.8010.24 (Official Build), stable
Safari: iOS 26.4
Additional context
Videos are attached showing:
- The content-sized drawer with one input in Chrome on iOS.
- The content-sized drawer with one input in Safari on iOS.
- The official documentation example in Chrome on iOS.
As a diagnostic experiment, I used a local workaround that synchronizes the viewport container’s position and height with window.visualViewport in response to viewport changes. This completely removes the issue in the minimal reproduction.
Videos demonstrating the issue:
Safari on iOS — content-sized drawer with a single input
https://github.com/user-attachments/assets/feee4601-3cab-49c3-a652-7ebedee778ec
Chrome on iOS — content-sized drawer with a single input
https://github.com/user-attachments/assets/8f316270-bf31-4be3-9bfa-b827602019fc
Chrome on iOS — official Virtual keyboard aware drawer example
https://github.com/user-attachments/assets/4c397ebb-0b1e-4f3b-8b7b-d3f788c9ee17
I can confirm this on the iOS 26.5 simulator (iPhone 17 Pro), with and without VirtualKeyboardProvider: a bottom drawer keeps its position when the keyboard opens, so with a header input and a list under it the last rows end up behind the keyboard. Measured: drawer top edge 112pt before and after, keyboard top edge at 590pt.
The behaviour described under "expected" here is what Vaul does with repositionInputs, and what #4688 implemented. Would you take that back as an opt-in, e.g. a prop on the provider (default off, so the current out-of-the-box behaviour stays)? I'm happy to open the PR, rebased on the provider, with the tests and a demo. It would also cover the shadcn combobox-in-drawer recipe, where the field is in the header and the list is what needs to stay reachable.
Drawer adds 48px of bottom-padding slack when an input is focused in the scrollable area, but that is seemingly too high especially for the layout shown. I will see what it looks like when reduced to 16px.
As for Chrome, the app I have on iPhone locally doesn't have the same bottom UI seen in your recording. I don't see the excessive slack when tapping an input (by that I mean well beyond 48px, because it matches Safari's padding). This could be affecting the measurements - what is the exact browser/version/settings used?
Unrelated: I've noticed tapping a label (not the input/textarea directly) on iOS 27 causes a glitchy scroll animation that isn't present on iOS 26, which I will look into.
@atomiks I noticed that the video headings were swapped and corrected the issue description.
The Chrome recording was made in the following environment:
- iPhone 14 Pro
- iOS 26.4
- Google Chrome 153.0.8010.24 (Official Build), stable
I also noticed a closing animation issue in the same minimal reproduction on Chrome on iOS.
After focusing the input and then closing the drawer, the exit animation appears slower and the drawer surfaces briefly overlap.
I tested the exact change from #5768 locally. It removes the additional bottom spacing in Safari, but the original Chrome issue and the closing animation issue both remain. This suggests that the Chrome-specific behavior has a different or additional cause.
My guess is that it may be related to how visualViewport changes are handled in Chrome on iOS, or to native focus scrolling while the keyboard is opening or closing.
I changed the background colors in the reproduction only to make the visual artifact easier to see. No layout or behavior logic was changed.
Environment:
- iPhone 14 Pro
- iOS 26.4
- Chrome 153.0.8010.24
https://github.com/user-attachments/assets/e907c981-a2a3-4ccd-8b42-a4ffd777ce6e
After uninstalling the Chrome app and reinstalling it, I got that new bottom black bar UI, and it's reproducible now. The new focus handling from the PRs linked above seems to let it self-correct after 150ms or so, but the animation looks very glitchy and in general it doesn't center correctly anymore when tapping inputs unlike with the old Chrome UI.
This fix will be available in the next npm release of Base UI.
In the meantime, use the canary build from PR #5774:
npm i https://pkg.pr.new/@base-ui/react@c2b97a7
This installs a complete package for @base-ui/react with the fix included. It is hosted by pkg.pr.new rather than npm, and the URL is available for up to six months.