Skip to content

fix: restore mouse hover after touchscreen use - #11052

Merged
tujoworker merged 2 commits into
mainfrom
fix/touch-mouse-hover-delay
Nov 24, 2026
Merged

tujoworker merged 2 commits into
mainfrom
fix/touch-mouse-hover-delay

Conversation

@tujoworker

@tujoworker tujoworker commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

After using the touchscreen on a device with both touch and a mouse, moving the mouse could leave hover styles turned off. Every mouse event restarted the 200 ms delay, so continuous movement could keep it going indefinitely.

Count the delay from the last touch event, including release. This also keeps a held tap from turning hover back on when the browser sends a compatibility mouse event after release. Mouse movement can restore hover after 200 ms, and the next touch turns it off again.

Keep the existing input tracking: a CSS query such as @media (hover: hover) tells us whether the browser's primary pointer can hover. It does not reliably tell us whether the user just touched the screen or used the mouse. On a hybrid device it can stay true during touch, so it cannot provide the same switching behavior. See the CSS specification.

@langz langz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! It's a small, targeted fix for a real issue.

Verified

  • I confirmed the root cause: on main, validateTouch reset the timestamp on every call, so continuous mouse movement kept data-whatintent="touch" indefinitely. It could even swallow a real mouse click made right after moving the mouse. Measuring from the last touch event fixes both.
  • I ran the new tests against main's implementation. All three fail with Expected: "mouse" / Received: "touch" and pass with this change, so they are proper regression tests. The "restarts the delay when touch movement continues" case also guards against only setting the timestamp on pointerdown.
  • I compared main and this branch on a fast tap (a compatibility mousedown 80 ms after the tap is still ignored), a slow tap, and pen hover followed by a mouse click. Both behave the same, so I see no regression for touch-only devices.
  • The JSDoc on validateTouch ("within 200 ms" of a touch) now matches the actual behavior.

Non-blocking, pre-existing (follow-up idea only)
Because the window starts at pointerdown, a tap held for more than 200 ms (without touch movement) lets the compatibility mousedown switch input and intent to mouse. This can bring back sticky hover on touch-only devices. It behaves the same on main, so it's out of scope here. If it matters, measuring from pointerup could be a follow-up.

No visual concerns: this is behavior-only, and visual regression and e2e checks pass.

@langz langz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 6ac22e1: Approve

The new commit acts on the follow-up from the earlier review: the 200 ms window now also restarts on touch release, so a held tap no longer lets the compatibility mousedown switch input back to mouse. I found no new defects. Tested merged with main at 4e63f4c.

Earlier findings

  • Resolved: a tap held for more than 200 ms let the compatibility mousedown switch input and intent to mouse. In real Chromium, a 350 ms held tap (CDP touch events) now ends as touch/touch; main ends as mouse/mouse.

What I checked

  • Trial merge with main at 4e63f4c: no conflicts. Main has not changed these files since the PR's base. A real trial merge with the newer main at ecaa2f5 is also clean. Its two new commits (Flex and Card) do not touch these files.
  • whatInput.test.ts on the merge: 13 of 13 pass. The related suites (component-helper, Accordion, SidebarMenuResponsive, DrawerList, MenuIntegration, FocusRing): 339 tests pass. Two SCSS snapshot tests timed out under load and passed alone.
  • The new tests fail without the fix. With main's whatInput.ts, 5 of 13 fail. With the first commit's whatInput.ts, the 2 held-tap tests (touch and pen) fail. The current head passes all 13.
  • Real browsers, on the main and PR previews, using synthetic events timed by the page:
    • Tap, then mouse moves 50 ms apart: main stays touch in Chromium and Firefox. The PR switches to mouse about 200 ms after the release.
    • Held tap (350 ms): main ends as mouse/mouse and the PR as touch/touch in Chromium, Firefox and WebKit.
    • Quick tap: the PR keeps touch/touch in all three engines.
    • A real mouse click 250 ms after a tap switches input and intent to mouse. A mouse move 250 ms after pointercancel (a touch that became a scroll) switches intent to mouse. Both behave the same on main and the PR, in all three engines.
  • Real taps (Playwright touch input) fire pointerdown, pointerup, then mousedown in all three engines. So listening to pointerup covers the compatibility event.
  • How this works with the @media (any-hover: hover) guards in the touch-hover PRs (for example #11007 and #11053): those guards still check data-whatintent. On a hybrid device, where any-hover: hover stays true, they depend on this change to bring hover back after the mouse moves. Keyboard intent is not affected: the 200 ms check runs only while the current input is touch.
  • Listeners and SSR: one more capture listener is added in the same one-time setUp, behind the existing document/window guard. The module never removes listeners, so nothing new needs cleanup.
  • ESLint and Prettier on both files: clean.

CI on 6ac22e113b: all 23 checks passed. Rechecked just before posting: the head is still 6ac22e1.

This branch was successfully deployed

2 active deployments
Package preview — 6ac22e11 Deployed Nov 24, 2026 by github-actions[bot]
Portal preview — 6ac22e11 Deployed Nov 24, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants