Skip to content

[menu] Open submenus on Android TalkBack press - #5384

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/elegant-chaum-9b849e
Jul 31, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:claude/elegant-chaum-9b849e

Conversation

@atomiks

@atomiks atomiks commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

A TalkBack double-tap on Menu.SubmenuTrigger with the default openOnHover does nothing. TalkBack activates elements with a virtual mouse press (1×1, zero-pressure pointerdown with pointerType: 'mouse', then mousedown and a detail: 0 click), so useClick latches mouse and ignoreMouse swallows the whole press — and the hover path can't rescue it since opening is gated on real mouse movement (allowMouseEnter).

useClick now latches 'virtual' as the pointer type when a mouse-like pointerdown matches isVirtualPointerEvent. The value isn't mouse-like, so ignoreMouse lets the press open on mousedown, while remaining truthy so the existing guard still swallows the trailing click (no immediate re-toggle when openOnHover={false}). Virtual touch presses (iOS VoiceOver) keep their type so touchOpenDelay still applies.

The tests live in a separate file because isVirtualPointerEvent only recognizes the TalkBack shape when the platform reports Android, so the file mocks @base-ui/utils/platform without leaking into sibling suites.

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

pkg-pr-new Bot commented Jul 31, 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@5384
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5384
    

commit: 27c56f1

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+50B(+0.01%) 🔺+19B(+0.01%)

Details of bundle changes

Performance

Total duration: 1,231.69 ms -202.18 ms(-14.1%) | Renders: 78 (+0) | Paint: 1,968.98 ms -267.80 ms(-12.0%)

Test Duration Renders
Slider mount (300 instances) 113.22 ms ▼-34.89 ms(-23.6%) 2 (+0)
Scroll Area mount (300 instances) 76.61 ms ▼-23.62 ms(-23.6%) 3 (+0)
Checkbox mount (500 instances) 63.96 ms ▼-16.78 ms(-20.8%) 1 (+0)
Dialog mount (300 instances) 51.08 ms ▼-15.35 ms(-23.1%) 1 (+0)

11 tests within noise — details


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

@netlify

netlify Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 27c56f1
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a6c0f902f269500070f8126
😎 Deploy Preview https://deploy-preview-5384--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 July 31, 2026 03:03
@atomiks

atomiks commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

Copy link
Copy Markdown

PR review

Nothing merge-blocking. The 'virtual' latch in useClick is behavior-neutral for every consumer except Menu.SubmenuTrigger with openOnHover (the intended fix): all other call sites use ignoreMouse: false, and 'virtual' behaves identically to 'mouse' in every remaining comparison (truthy for the trailing-click swallow, not 'touch' for touchOpenDelay, cleared on keydown). iOS VoiceOver presses keep pointerType: 'touch' as the comment claims. The first test fails on the base commit, so the fix is properly pinned, and the platform mock matches the module's single platform export and the established .android/.iOS test-file precedent. Two informational notes below.

Bugs (2)

1. ℹ️ Desktop 0×0 virtual-pointer heuristic now gates open logic, not just focus

Location: packages/react/src/floating-ui-react/hooks/useClick.ts:137

pointerTypeRef.current =
  isMouseLikePointerType(event.pointerType, true) &&
  isVirtualPointerEvent(event.nativeEvent)
    ? 'virtual'
    : event.pointerType;

On non-Android platforms, isVirtualPointerEvent matches any pointerdown with width === 0 && height === 0 — no pressure/detail guard (utils/event.ts:30). Until now that heuristic only fed focus behavior (useListNavigation, FloatingFocusManager), where a false positive is cosmetic; here it bypasses ignoreMouse, so a desktop mouse/pen whose driver or browser reports zero contact geometry would open a hover submenu instantly on mousedown, skipping the hover delay and the allowMouseEnter gate.

Failure scenario: A digitizer/stylus (reported as pen) or a browser quirk emitting 0×0 mouse pointer events presses a Menu.SubmenuTrigger with default openOnHover — the submenu opens immediately instead of deferring to hover logic. Open-only (toggle: false prevents accidental close), and mainstream browsers report 1×1 for real mice, so this is a heads-up about the heuristic's enlarged blast radius rather than a reproducible bug.

Fix: None required; optionally tighten the non-Android branch (e.g. also require pressure === 0 && detail === 0) if false positives ever surface — though the 0×0 shape is exactly the desktop screen-reader press the comment intends to support.

2. ℹ️ Virtual presses can open a hover submenu but never close it from the trigger

Location: packages/react/src/menu/submenu-trigger/MenuSubmenuTrigger.tsx:159

toggle: !openOnHover,
ignoreMouse: openOnHover,

With default openOnHover, toggle is false, so a second TalkBack double-tap on the trigger keeps the submenu open, and the hover close path (safePolygon / mouseleave) never fires for a virtual pointer. Mouse users can close by hovering away; TalkBack users must use Escape/back gesture or dismiss the root.

Failure scenario: TalkBack user opens the submenu via the new path, double-taps the trigger again expecting it to collapse — nothing happens.

Fix: Likely acceptable (consistent with the non-toggle contract for hover triggers, and back gesture/Escape work); flagging so it's a deliberate choice rather than an accident.

Verdict

Approve — no user-visible regressions found; the change is narrowly scoped to the intended TalkBack path and is pinned by a test that fails on the base commit.


🤖 Review generated with Claude Code

@atomiks
atomiks merged commit dc9a457 into mui:master Jul 31, 2026
6 checks passed
@atomiks
atomiks deleted the claude/elegant-chaum-9b849e branch July 31, 2026 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant