Angular (zoneless): `enabled` is applied in an effect, so a key matched before the next change detection sees the old value
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- angular, typescript
- 领域
- frontend
调研方向
Start with the Angular adapter's injectHotkeys implementation and trace how enabled reaches the hotkey manager's #isLive matching path. Use the linked StackBlitz reproduction to compare nested-scope behavior when enabled changes before another keydown. Done means the inner handler stops running after its scope is disabled and the parent handles subsequent keys; check whether a fix affects other adapters or core behavior.
由索引模型根据 Issue 内容生成。
描述
TanStack Hotkeys version
@tanstack/angular-hotkeys 0.25.2 (@tanstack/hotkeys 0.33.0)
Framework/Library version
Angular 22.2.3
Describe the bug and the steps to reproduce it
injectHotkeys applies a reactive enabled from an Angular effect, so the manager only sees the new value after the next change detection. A key that arrives before then is matched against the old value. When one handler disables a nested scope, the next key runs that scope's handler instead of falling through to the parent.
Hand-typed keys usually leave time for change detection, so this mostly shows with programmatic events and automated tests. This is not #105 (callback form to avoid re-registration). The issue is when enabled is read, not how often the registration is updated.
Example: nested scopes bind ArrowDown. The inner one moves a row while row < 4, the outer one logs a "cross". Eight presses should give four moves, then four crosses.
Steps (fail every run in Chromium and Firefox):
- Click "Set row to 4, then one keydown, in one task". Expected
cross at 4, actualmove from 4. - Click Reset, then "Dispatch 8 keydowns in one task". Expected 4 moves then 4 crosses, actual 8 moves.
Runs that gave the expected log, of 20 (Playwright 1.64.1, Chromium 156, Firefox 157):
| Input | Chromium | Firefox |
|---|---|---|
| Steps 1 and 2 | 0 | 0 |
Eight keyboard.press |
1 | 20 |
Eight keyboard.down (held) |
0 | 20 |
Workaround: a capture-phase keydown listener on an ancestor that calls ApplicationRef.tick().
Possible fixes (ideas only, not checked against other adapters or the core):
enabled?: boolean | (() => boolean), read when the key is matched (#isLive).- A hook that runs before matching, so an adapter can flush pending effects.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
https://stackblitz.com/edit/stackblitz-starters-xxhahcn7
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
- 主要语言
- TypeScript
- 星标
- 761
- 派生
- 50
- 平均合并
- 6 小时 51 分钟
- 30 天内合并 PR
- 68
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/hotkeys 的其他 Issue
相似的 Issue
-
inference/go type/feature
难度 1/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#65148 · 1 条评论 ·
维护者通常 1 天内回复
-
truapi-release
难度 2/5 1-3 小时 新手友好度 72/100
paritytech/product-sdk#529 ·
维护者通常 1 天内回复
-
Add: Mansudae TV未关闭approved check:passed streams:add
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per node未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
devlikeapro/waha#2369 ·
维护者通常 5 天内回复