fix(usePointer): reset isInside on pointercancel - #5587
Conversation
When the browser abandons a gesture it fires pointercancel without pointerleave reaching the element (e.g. the pointer is under setPointerCapture and retargeted away), leaving isInside stuck at true. Follow-up of the same class of fixes as vueuse#5550 (useDraggable) and vueuse#5555 (onLongPress). Closes vueuse#5586.
There was a problem hiding this comment.
Pull request overview
This PR fixes a stuck isInside state in usePointer by ensuring it resets not only on pointerleave, but also on pointercancel (which can occur without pointerleave reaching the element when the browser cancels a gesture).
Changes:
- Add a
pointercancellistener alongsidepointerleaveto resetisInside. - Add unit tests covering
isInsidereset behavior for bothpointercancelandpointerleave.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/usePointer/index.ts | Reset isInside on pointercancel in addition to pointerleave. |
| packages/core/usePointer/index.test.ts | Add tests asserting isInside resets on pointercancel and pointerleave. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks for the review @OrbisK! It looks like the CI run is stuck in |
@vueuse/components
@vueuse/core
@vueuse/electron
@vueuse/firebase
@vueuse/integrations
@vueuse/math
@vueuse/metadata
@vueuse/nuxt
@vueuse/router
@vueuse/rxjs
@vueuse/shared
@vueuse/skills
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5587 +/- ##
==========================================
+ Coverage 68.38% 68.56% +0.18%
==========================================
Files 350 350
Lines 8324 8324
Branches 2548 2536 -12
==========================================
+ Hits 5692 5707 +15
+ Misses 2149 2137 -12
+ Partials 483 480 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: unkizhang <unkizhang@tencent.com> (cherry picked from commit 8b7f45d)
Description
usePointeronly resetisInsideonpointerleave. When the browser abandons a gesture it firespointercancelwithoutpointerleavereaching the element (e.g. when the pointer is undersetPointerCaptureand gets retargeted away), leavingisInsidestuck attrue.Changes
pointercancelin addition topointerleaveto resetisInside(1-line change)index.test.tsforusePointercovering bothpointercancelandpointerleavereset behaviorContext
This is the same class of fixes as:
useDraggablepointercancel)onLongPresspointercancel) — its PR description mentionedusePointerwould follow as a separate PRCloses #5586