Skip to content

Sheet focus trap: Tab escapes during the open tween, and the backdrop is an unnamed button #310

Closed

Description

@HMarzban

Problem

Two gaps remain in the BottomSheet focus trap from #248:

  1. Tab can leave a sheet before onOpenEnd, while the open tween runs. A probe saw focus reach a focus guard and the backdrop.
  2. The react-modal-sheet 5.6.0 backdrop renders as an unlabeled <button> when it has onTap. It sits in the tab order, and screen readers announce it with no name.

Fix

  • Arm the trap, or move focus into the sheet, before the tween ends.
  • Give the backdrop aria-hidden and tabIndex={-1}, or an accessible name such as "Close sheet". Check the react-modal-sheet API first.

Check

At 390x844, open a sheet and press Tab at once, 15 times. Focus stays inside the sheet. The backdrop is not a Tab stop.

Part of #249.

Activity

  1. added
    bug
    on Sep 23, 2026
  2. added this to the v2.3.0 milestone on Oct 24, 2026
  3. HMarzban commented on Oct 25, 2026

    @HMarzban
    CollaboratorAuthor

    Built and committed on local main. Awaits the maintainer's final push.

    Remaining gates: the webapp deploy, then the iOS Safari and Android Chrome checks in the device session.

  4. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03. The focus trap fix shipped in bd71f714f, with a review follow-up in 5cfcc023d. It is pushed and deployed. Left:

  5. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Fix, 2026-11-03. 7d41263a8. Committed on local main, not pushed yet; the commit link resolves after the push.

    The caveat was worse than one beat. In Document settings, Shift+Tab from Close went to the sheet container, then to floating-ui's before-guard outside the dialog, and the two traded focus without reaching the other controls. A trapped sheet now wraps Tab and Shift+Tab at its own edges. A radio group counts as one stop, as the browser does, and a control that refuses focus is skipped. Checked on Android in Document settings and in the link sheet: both directions cycle inside, and Escape returns focus to the opener.

    Still open here: the iOS leg.

  6. HMarzban commented on Nov 3, 2026

    @HMarzban
    CollaboratorAuthor

    Status, 2026-11-03 (after the 1b05cb2 deploy). 7d41263a8 is on main. It shipped in deploy run 41677887088 (head 1b05cb24d).

    • A trapped sheet now wraps Tab and Shift+Tab at its own edges.
    • A radio group counts as one stop.
    • The backdrop renders with aria-hidden and tabIndex={-1} (Sheet.Backdrop in BottomSheet.tsx).

    The Android check passed on the local stack before the push, in Document settings and the link sheet. Left:

    • The iOS leg of the Tab check.
  7. HMarzban commented on Nov 4, 2026

    @HMarzban
    CollaboratorAuthor

    Simulator check, 2026-11-04. The iOS leg is not run. This Mac cannot send a real Tab key to the iPhone simulator (iPhone 17 Pro, iOS 26.5, Xcode 27.2).

    • The simulator tool cannot type a tab character, and its key action has no Tab.
    • Simulator.app is not installed with this Xcode, so "Connect Hardware Keyboard" is not available.
    • idb is not installed, and simctl has no key command.
    • A probe page counted 0 Tab keydowns.

    Under the 2026-11-03 ruling a simulator may still close this leg once it has a Tab source: Simulator.app with Connect Hardware Keyboard, or idb (idb ui key 43). Without one, the leg needs a real iPhone with a hardware keyboard.

    The re-run plan:

    1. Check that Safari's Tab reaches buttons and radios, not only text fields.
    2. Open Document settings, which has the radio group.
    3. Send 15 Tab presses, then 15 Shift+Tab presses. Focus must stay in the sheet and wrap at both edges.
    4. Press Escape. Focus must return to the opener.

    Note: the simulator screens here are 402×874 and 393×852 points, not 390×844.

  8. HMarzban commented on Nov 9, 2026

    @HMarzban
    CollaboratorAuthor

    Simulator check, 2026-11-09. QA iPhone 17 Pro simulator, iOS 26.5, Safari 26.5. Keys came from idb ui key 43 (Tab) and --shift. Owner pad, local stack.

    The Tab leg cannot run on this setup. idb keys reach the page only while a text field has focus. On a probe page, Tab from a text field skipped a button and two radios and left the page.

    What did run, in Document settings:

    • Open tween: 15 Tab and 15 Shift+Tab sent at once after the open tap. 0 of 30 reached the page. Focus went to the sheet container and stayed there.
    • Tab from Description: 2 of 30 arrived. Description → Keywords, then the floating-ui after-guard, then Close inside the sheet in the same millisecond. So the trap pulled focus back.
    • Shift+Tab from Description: 1 of 15 arrived. Focus landed on the sheet container, inside.
    • Escape: the sheet closed, and focus returned to Open menu, the opener.
    • Backdrop: aria-hidden="true" and tabindex="-1" (BottomSheet.tsx:317). It is not a Tab stop. The Fix section allows this option instead of a name, so that part is done.

    Left:

    • [maintainer] On a real iPhone or iPad with a hardware keyboard: 15 Tab presses at once during the open tween, then 15 Tab and 15 Shift+Tab. Focus must stay in the sheet.
  9. HMarzban commented on Nov 9, 2026

    @HMarzban
    CollaboratorAuthor

    Maintainer ruling, 2026-11-09

    The real-device Tab leg (iPhone with a hardware keyboard, Document settings, Tab and Shift+Tab during and after the open tween) is approved by the maintainer. The fix is on production, and the simulator run above showed that every key that reached the page stayed inside the sheet. Every box is met. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MobileUIbug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions