Skip to content

fix(useHover): prevent stuck hover state in useHover after touch interactions - #10824

Merged
reidbarber merged 1 commit into
mainfrom
fix-stuck-hover-state-on-touch
Oct 22, 2026
Merged

reidbarber merged 1 commit into
mainfrom
fix-stuck-hover-state-on-touch

Conversation

@reidbarber

Copy link
Copy Markdown
Member

Closes #10823

On hybrid touch+mouse devices, elements can get stuck in an isHovered state after a touch interaction.

This is because in useHover, triggerHoverEnd cleared state.target before its early return for touch events. When a touch happened while an element was mouse-hovered, that element was left with isHovered = true but no target, so nothing could end the hover until it unmounted.

This PR:

  • Moves the state.target / state.pointerType updates in triggerHoverStart and triggerHoverEnd after their early returns, so ignored touch events no longer change hover state.
  • Clears the previous timeout in setGlobalIgnoreEmulatedMouseEvents, so a second tap within 500ms gets the full window for ignoring emulated mouse events.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices
  • I understand every change in this PR and can explain why it's there.
  • If AI-assisted, I followed our AI contribution guidance and pointed my assistant at AGENTS.md.

📝 Test Instructions:

Unit tests should cover this, but on a physical device with both touch and mouse, you can test this by going to the useHover docs example, then:

  1. Hover "Hover me!" with your mouse.
  2. Without moving the mouse, tap somewhere else on the page.
  3. Move the mouse off the button.

Previously the button would stay dark green (hover state) and the log would show "hover start with mouse" with no "hover end".

🧢 Your Project:

@nwidynski

Copy link
Copy Markdown
Contributor

LGTM :)

@reidbarber
reidbarber enabled auto-merge October 22, 2026 02:01
@reidbarber
reidbarber added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit d243d50 Oct 22, 2026
31 checks passed
@reidbarber
reidbarber deleted the fix-stuck-hover-state-on-touch branch October 22, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants