fix(core): suppress tooltip hover on touch pointer events#933
Draft
fix(core): suppress tooltip hover on touch pointer events#933
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
📦 Bundle Size Report🎨 @videojs/html(no changes) Presets (7)
Media (4)
Players (3)
Skins (16)
UI Components (21)
Sizes are marginal over the root entry point. ⚛️ @videojs/react(no changes) Presets (7)
Media (3)
Skins (14)
UI Components (17)
Sizes are marginal over the root entry point. 🧩 @videojs/core(no changes) Entries (5)
🏷️ @videojs/element(no changes) Entries (2)
📦 @videojs/store(no changes) Entries (3)
🔧 @videojs/utils(no changes) Entries (10)
📦 @videojs/spf(no changes) Entries (3)
ℹ️ How to interpretAll sizes are standalone totals (minified + brotli).
Run |
Add two-part touch suppression in the tooltip layer (matching Radix): 1. pointerType === 'touch' guard on onPointerEnter blocks touch hover 2. isPointerDown flag gates onFocusIn so tap-triggered focus is suppressed while keyboard focus (Tab) continues to work The fix is scoped to tooltips so popovers with openOnHover continue to work with touch as expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #921
Summary
Tooltips incorrectly open on touch interactions on hybrid devices (e.g. touchscreen laptops). The popover layer's
canHover()guard usesmatchMedia('(hover: hover)')which describes device capability, not current input method — so it always matches on hybrid devices even during touch input.Adds a two-part touch suppression in the tooltip layer, following the pattern used by Radix UI:
pointerType === 'touch'guard inonPointerEnter— blocks touch-triggered hoverisPointerDownflag viaonPointerDown/onPointerUpintriggerProps, checked inonFocusIn— suppresses tap-triggered focus (browser firespointerdown → focus → pointerup, so the flag is set during tap but not during keyboard Tab)Both handlers are exposed through
triggerPropsso the framework layer (HTML/React) attaches them — no imperativelisten()calls.Changes
onPointerDownandonPointerUptoTooltipTriggerPropsinterfaceevent.pointerType === 'touch'early return inonPointerEnterisPointerDownflag checked inonFocusInto distinguish tap-focus from keyboard-focusDesign decisions
Why tooltip layer, not popover? Base UI recommends
PopoverwithopenOnHoveras the touch-accessible alternative to tooltips. Blocking touch in the popover layer would break that use case. The guard belongs specifically in the tooltip layer.Why not long-press? Researched Base UI and Radix — both disable tooltips on touch entirely. Long-press conflicts with browser context menus and delays primary button actions in a video player.
Why
pointerTypeover(hover: hover)? The media query is device-level;pointerTypeis per-event. On a hybrid device with trackpad + touchscreen,(hover: hover)is always true, butpointerTypecorrectly reports'touch'vs'mouse'per interaction.Why the
isPointerDownpattern? A touch tap firespointerdown → focus → pointerup. Without this guard, the tooltip would open via thefocusinhandler even though hover was suppressed. The flag distinguishes tap-triggered focus (pointer is down) from keyboard Tab focus (pointer is not down). This is the same pattern Radix uses.Testing
pnpm -F @videojs/core test src/dom/ui/tooltip5 new tests in "touch pointer suppression" block: