Skip to content

[drawer] Fix native focus scrolling on iOS 27 - #5769

Merged
atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/drawer-ios27-focus-scroll
Sep 22, 2026
Merged

atomiks merged 1 commit into
mui:masterfrom
atomiks:codex/drawer-ios27-focus-scroll

Conversation

@atomiks

@atomiks atomiks commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Fixes native page scrolling in Drawer.VirtualKeyboardProvider on iOS 27 when tapping a label with the keyboard closed or moving focus with the keyboard's previous/next buttons. Lower fields could push the drawer offscreen or cause a visible jump before the page position was restored.

  • Reapply preventScroll after label activation, which otherwise replaces the pending focus options while the keyboard is opening. Preserve click delivery and consumer focus changes.
  • Apply preventScroll during capture-phase focus for native field navigation, before WebKit records its focus options. Retain the existing geometry protection and delayed alignment without adding a blur/focus cycle.
  • Cover explicit and wrapping labels, native focus ordering, and consumer focus redirection.

Confirmed on a physical iOS 27 device and checked in iOS 26.5 Simulator with label/input taps, textarea/footer transitions, and both keyboard-arrow directions. All 58 provider tests pass in Chromium; the affected regression tests fail without the fixes.

Related to #5766. This addresses the separately observed focus-scrolling bugs; it does not establish a fix for the original Chrome report or change keyboard scroll slack.

@atomiks atomiks added type: bug It doesn't behave as expected. component: drawer Changes related to the drawer component. labels Sep 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5769
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5769
    

commit: 0f2c8f5

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+137B(+0.03%) 🔺+36B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,003.84 ms +54.31 ms(+5.7%) | Renders: 76 (+0) | Paint: 1,698.56 ms +102.44 ms(+6.4%)

Test Duration Renders
Slider mount (300 instances) 110.31 ms 🔺+22.59 ms(+25.8%) 2 (+0)
Select open (500 options) 47.77 ms 🔺+11.76 ms(+32.7%) 14 (+0)
Tooltip mount (300 contained roots) 57.91 ms 🔺+11.28 ms(+24.2%) 1 (+0)

12 tests within noise — details

Metric alarms

Test Metric Change
Slider mount (300 instances) bench:paint 🔺 +41.61 ms
Tooltip mount (300 contained roots) bench:paint 🔺 +16.42 ms

Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0f2c8f5
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6ab1e580a5465b00081e43cc
😎 Deploy Preview https://deploy-preview-5769--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review September 21, 2026 02:04
@atomiks
atomiks force-pushed the codex/drawer-ios27-focus-scroll branch from 951cb9b to 0f2c8f5 Compare September 22, 2026 02:18
@atomiks
atomiks merged commit 540c176 into mui:master Sep 22, 2026
24 checks passed
zernonia added a commit to unovue/reka-ui that referenced this pull request Sep 28, 2026
Port the latest Base UI `DrawerVirtualKeyboardProvider` changes:
- Remove the extra keyboard scroll slack; pad by the overlap on top of at
  least the visibility margin (mui/base-ui#5768).
- Reapply `preventScroll` on native focus before `focusin` for iOS 27, and
  after a tapped label refocuses its control (mui/base-ui#5769).
- Track the keyboard across Chrome on iOS resizing the layout viewport, with
  an `svh` probe, a `resizing` guard and a window resize listener
  (mui/base-ui#5774).
- Find the scroll container across shadow roots (mui/base-ui#5360).

Also check for DrawerViewport once DrawerContent mounts, like Base UI's
popup, so a drawer that starts open no longer logs a false warning.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
zernonia added a commit to unovue/reka-ui that referenced this pull request Sep 28, 2026
#2889)

* feat(Drawer): add DrawerVirtualKeyboardProvider for software keyboards

The software keyboard slides over the bottom of the viewport without
resizing it, so a bottom-anchored drawer — and the field the user just
tapped — end up underneath it (#2877).

Wrapping the drawer in `DrawerVirtualKeyboardProvider` opts into
keyboard-aware focus and scroll handling: while a field inside the drawer
is focused it publishes the keyboard height as `--drawer-keyboard-inset`
on `DrawerViewport` (or the popup, when no viewport is used) and keeps the
field scrolled into the band left visible above the keyboard, adding
temporary slack to its scroller when the field would otherwise sit below
the scrollable range.

It also defends against WebKit: a tap on a field is focused synchronously
with the field's painted geometry overridden so the native reveal cannot
drag a transformed sheet, native focus moves are preempted the same way,
and a modal drawer pins the page against reveal scrolls the scroll lock
cannot hold. Alignment is suspended while pinch-zoomed or while a nested
drawer is open, and viewport changes under 60px are treated as browser
chrome rather than the keyboard.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor(Drawer): pass view on the redispatched keyboard tap click

Matches Base UI, falling back to an init without `view` where the window
fails the realm check (jsdom). Restores lean Base UI references in the
ported code.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* refactor(Drawer): require DrawerViewport for the virtual keyboard provider

Matches Base UI: the viewport wraps the popup, acts as the measurement and
containment root, and hosts `--drawer-keyboard-inset` for the popup and
everything inside it. Warns in development when it is missing instead of
falling back to the popup.
 

* fix(Drawer): address review feedback on the virtual keyboard provider

- `DrawerViewport` now remembers the element it registered on the root
  context. Vue nulls the template ref before `onUnmounted` runs, so the
  identity check against `currentElement` never matched and the root kept
  a detached viewport.
- `useDrawerVirtualKeyboard` resolves `getComputedStyle` / `matchMedia`
  from the element's own window, like the rest of the composable.
- Tests restore fake timers, `innerHeight`, `scrollTo`, `scrollY` and
  `elementFromPoint` in `afterEach` so cases stay order-independent, and
  a new case covers the viewport teardown.

 

* test(Drawer): restore the original innerHeight descriptor after keyboard tests

jsdom defines `window.innerHeight` as an own property, so deleting it in
teardown left the window without one. Capture the descriptor before
stubbing and put it back.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(Drawer): sync the virtual keyboard provider with upstream Base UI

Port the latest Base UI `DrawerVirtualKeyboardProvider` changes:
- Remove the extra keyboard scroll slack; pad by the overlap on top of at
  least the visibility margin (mui/base-ui#5768).
- Reapply `preventScroll` on native focus before `focusin` for iOS 27, and
  after a tapped label refocuses its control (mui/base-ui#5769).
- Track the keyboard across Chrome on iOS resizing the layout viewport, with
  an `svh` probe, a `resizing` guard and a window resize listener
  (mui/base-ui#5774).
- Find the scroll container across shadow roots (mui/base-ui#5360).

Also check for DrawerViewport once DrawerContent mounts, like Base UI's
popup, so a drawer that starts open no longer logs a false warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant