Skip to content

fix(onKeyStroke): register listener as passive instead of capture - #5621

Open
lazerg wants to merge 2 commits into
vueuse:mainfrom
lazerg:fix/onkeystroke-passive-capture-5620
Open

lazerg wants to merge 2 commits into
vueuse:mainfrom
lazerg:fix/onkeystroke-passive-capture-5620

Conversation

@lazerg

@lazerg lazerg commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

onKeyStroke passed the passive boolean straight through as useEventListener's options argument, and addEventListener treats a boolean there as useCapture, not passive. So passive: true silently turned the listener into a capture-phase one, letting it run before a descendant's own handler had a chance to call stopPropagation().

Wrapped it as { passive } so the browser reads it as the intended passive option and the listener stays in the default bubble phase. onKeyStroke doesn't expose any other listener option (no capture, once, etc.), so there's nothing else to forward here.

One side effect worth flagging: since passive listeners can't call preventDefault(), any handler that relied on the old (buggy) capture-mode listener actually running preventDefault() will now find it's a no-op, which is the correct passive contract but a behavior change from before.

Fixes #5620

@agentscanapp

agentscanapp Bot commented Sep 4, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! 🎉

We really appreciate you taking the time to contribute, @lazerg.

A maintainer will take a look as soon as they can. In the meantime, please make sure that:

  • the description explains what changed and why
  • any related issues are linked
  • existing tests still pass

If anything needs adjusting we'll leave comments here. Thanks again!

@agentscanapp

agentscanapp Bot commented Sep 4, 2026

Copy link
Copy Markdown

Automation signals

Activity patterns show signs of automation.

View full analysis →

Report this account →

Evidence
  • High PR volume (weekly): 62 PRs within a single 7-day window
  • Rapid fork→PR pattern: 39/42 fork branches followed by upstream PRs within 90s
  • Multiple forks: 5 repositories forked in a single 24-hour window

Last 5 PRs:

This is an automated analysis by AgentScan

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vueuse/components

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

@vueuse/core

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

@vueuse/electron

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

@vueuse/firebase

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

@vueuse/integrations

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

@vueuse/math

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

@vueuse/metadata

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

@vueuse/nuxt

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

@vueuse/router

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

@vueuse/rxjs

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

@vueuse/shared

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

@vueuse/skills

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

commit: a7edbdd

@lazerg

lazerg commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

This pipeline failure predates my change and isn't caused by it. It's the known flaky useTransition animation-timing test, unrelated to onKeyStroke.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.09%. Comparing base (97fd09c) to head (a7edbdd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5621   +/-   ##
=======================================
  Coverage   69.09%   69.09%           
=======================================
  Files         351      351           
  Lines        8355     8355           
  Branches     2542     2554   +12     
=======================================
  Hits         5773     5773           
  Misses       2110     2110           
  Partials      472      472           

☔ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG | onKeyStroke() | Registers a capture listener when passive: true

1 participant