Skip to content

fix(usePointer): reset isInside on pointercancel - #5587

Merged
antfu merged 1 commit into
vueuse:mainfrom
haoku123:fix/usePointer-pointercancel
Aug 20, 2026
Merged

antfu merged 1 commit into
vueuse:mainfrom
haoku123:fix/usePointer-pointercancel

Conversation

@haoku123

Copy link
Copy Markdown
Contributor

Description

usePointer only reset isInside on pointerleave. When the browser abandons a gesture it fires pointercancel without pointerleave reaching the element (e.g. when the pointer is under setPointerCapture and gets retargeted away), leaving isInside stuck at true.

Changes

  • Listen for pointercancel in addition to pointerleave to reset isInside (1-line change)
  • Added index.test.ts for usePointer covering both pointercancel and pointerleave reset behavior

Context

This is the same class of fixes as:

Closes #5586

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.
Copilot AI lite review requested due to automatic review settings August 14, 2026 06:16
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Aug 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 pointercancel listener alongside pointerleave to reset isInside.
  • Add unit tests covering isInside reset behavior for both pointercancel and pointerleave.

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.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 14, 2026
@haoku123

Copy link
Copy Markdown
Contributor Author

Thanks for the review @OrbisK! It looks like the CI run is stuck in action_required (waiting for workflow approval on this fork PR). Would it be possible to approve the workflow run so the tests can execute? The change is small (reset isInside on pointercancel + regression test) and should pass cleanly. Thanks!

@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vueuse/components

pnpm add https://pkg.pr.new/@vueuse/components@5587
npm i https://pkg.pr.new/@vueuse/components@5587
yarn add https://pkg.pr.new/@vueuse/components@5587.tgz

@vueuse/core

pnpm add https://pkg.pr.new/@vueuse/core@5587
npm i https://pkg.pr.new/@vueuse/core@5587
yarn add https://pkg.pr.new/@vueuse/core@5587.tgz

@vueuse/electron

pnpm add https://pkg.pr.new/@vueuse/electron@5587
npm i https://pkg.pr.new/@vueuse/electron@5587
yarn add https://pkg.pr.new/@vueuse/electron@5587.tgz

@vueuse/firebase

pnpm add https://pkg.pr.new/@vueuse/firebase@5587
npm i https://pkg.pr.new/@vueuse/firebase@5587
yarn add https://pkg.pr.new/@vueuse/firebase@5587.tgz

@vueuse/integrations

pnpm add https://pkg.pr.new/@vueuse/integrations@5587
npm i https://pkg.pr.new/@vueuse/integrations@5587
yarn add https://pkg.pr.new/@vueuse/integrations@5587.tgz

@vueuse/math

pnpm add https://pkg.pr.new/@vueuse/math@5587
npm i https://pkg.pr.new/@vueuse/math@5587
yarn add https://pkg.pr.new/@vueuse/math@5587.tgz

@vueuse/metadata

pnpm add https://pkg.pr.new/@vueuse/metadata@5587
npm i https://pkg.pr.new/@vueuse/metadata@5587
yarn add https://pkg.pr.new/@vueuse/metadata@5587.tgz

@vueuse/nuxt

pnpm add https://pkg.pr.new/@vueuse/nuxt@5587
npm i https://pkg.pr.new/@vueuse/nuxt@5587
yarn add https://pkg.pr.new/@vueuse/nuxt@5587.tgz

@vueuse/router

pnpm add https://pkg.pr.new/@vueuse/router@5587
npm i https://pkg.pr.new/@vueuse/router@5587
yarn add https://pkg.pr.new/@vueuse/router@5587.tgz

@vueuse/rxjs

pnpm add https://pkg.pr.new/@vueuse/rxjs@5587
npm i https://pkg.pr.new/@vueuse/rxjs@5587
yarn add https://pkg.pr.new/@vueuse/rxjs@5587.tgz

@vueuse/shared

pnpm add https://pkg.pr.new/@vueuse/shared@5587
npm i https://pkg.pr.new/@vueuse/shared@5587
yarn add https://pkg.pr.new/@vueuse/shared@5587.tgz

@vueuse/skills

pnpm add https://pkg.pr.new/@vueuse/skills@5587
npm i https://pkg.pr.new/@vueuse/skills@5587
yarn add https://pkg.pr.new/@vueuse/skills@5587.tgz

commit: 4a4d9a4

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.56%. Comparing base (4ed28fb) to head (4a4d9a4).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antfu
antfu added this pull request to the merge queue Aug 20, 2026
Merged via the queue into vueuse:main with commit 8b7f45d Aug 20, 2026
12 checks passed
antfu pushed a commit that referenced this pull request Aug 20, 2026
Co-authored-by: unkizhang <unkizhang@tencent.com>
(cherry picked from commit 8b7f45d)
@OrbisK OrbisK mentioned this pull request Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

usePointer's isInside doesn't clear on pointercancel, only pointerleave

5 participants