Skip to content

Bottom Sheet: keyboard users cannot scroll the sheet body (axe serious) #5207

Closed

Description

@imdreamrunner

Bug: a keyboard user cannot scroll the Bottom Sheet's content when that content has no focusable elements.

The scrolling area has no tabIndex, so it never takes focus, so arrow keys and Page Down do nothing. A sheet full of plain text is unreachable by keyboard. A sheet with a button inside is fine — focus lands there and scrolls the area.

axe calls this scrollable-region-focusable, severity serious.

How it surfaced. CI's a11y job audits Storybook stories. No Bottom Sheet story had ever rendered open, so nothing was ever checked. A story in PR #5203 did open, and the audit failed immediately. I closed that story to unblock the PR — the bug is older and not from that change.

The fix is not one line. Adding tabIndex={0} to the scroll body adds a tab stop to every sheet, including ones that do not need it. It probably needs to be conditional on the content having no focusable children, which is a runtime check and wants its own review.

Also worth fixing: at least one Bottom Sheet story should render open, or CI will keep missing this whole component.

Files: packages/core/src/BottomSheet/BottomSheetPanel.tsx (the styles.body div).

Rule: https://dequeuniversity.com/rules/axe/4.12/scrollable-region-focusable

Activity

  1. HelloOjasMutreja commented on Aug 19, 2026

    @HelloOjasMutreja
    Contributor

    Proposed approach for the conditional tabIndex, since you flagged this needs its own review rather than a blind one-liner.

    BottomSheetPanel.tsx already threads a ref to the scroll body div: bodyElementRef (from useSheetGestures, merged into bodyProps and applied to the styles.body div around line 530). That's the ref to hang the check on rather than adding a new one.

    For the focusable-descendant check itself, useFocusTrap.ts already has exactly this logic via FOCUSABLE_SELECTOR (from ../hooks/focusableSelector.ts, module-internal but not barrel-exported, explicitly documented as "shared by focus-management hooks so the selector isn't duplicated"). Since BottomSheetPanel.tsx lives in the same package, it can import it directly rather than reimplementing the selector.

    Sketch:

    import {FOCUSABLE_SELECTOR} from '../hooks/focusableSelector';
    
    const [bodyNeedsTabIndex, setBodyNeedsTabIndex] = useState(false);
    
    useLayoutEffect(() => {
      const body = bodyElementRef.current;
      if (!body) return;
      setBodyNeedsTabIndex(!body.querySelector(FOCUSABLE_SELECTOR));
    }, [children, bodyElementRef]);

    then tabIndex={bodyNeedsTabIndex ? 0 : undefined} on the body div, so a sheet with a real focusable control (the common case) gets no extra tab stop, and a text-only sheet becomes keyboard-focusable and scrollable.

    Re-checking on children covers the sheet's own re-render path; it wouldn't catch a focusable element added by some deeper async child after this effect runs without its own re-render bubbling up, but that's the same boundary useFocusTrap's existing focusable-scan has, so it'd be consistent with this codebase's existing precedent rather than a new gap.

    On the second point in the issue (no Bottom Sheet story ever renders open, so CI's a11y job never caught this): I'd add that as part of the same PR, an open-by-default story for exactly the "sheet with no focusable content" case, since that's the one this fix targets and the one CI needs actual coverage of going forward.

    Let me know if this matches what you had in mind, or if you'd rather see it land differently, before I implement.

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

    accessibilityarea:corebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions