Skip to content

fix(wheel): 数字键恒选花瓣不串搜索;超范围给 keyRange 提示 - #18

Merged
Haaaiawd merged 2 commits into
masterfrom
fix/wheel-page-hotkey
Oct 18, 2026
Merged

Haaaiawd merged 2 commits into
masterfrom
fix/wheel-page-hotkey

Conversation

@Haaaiawd

@Haaaiawd Haaaiawd commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

问题

轮盘有第二页时,按 7/8/9(以及短页的超范围数字)会掉进打字过滤分支,query += e.key 把数字塞进搜索框——搜索内容突然变了,用户完全不知道发生了什么。

用户原话:「现在轮盘会有第二页,但是前端第二页第一个会显示 1,但是其实对应的快捷键应该是 7 对不对?还是 1 呢?」

定案:还是按 1(页内序号)

序号与按键的对应关系本来就没断(花瓣画 1,按 1 选它)。真正断的是无效数字键的处置。

不改成全局序号(按 7)的理由:键盘只有 1-9,PAGE=6,第二页要按 7-12,第三页直接没键可用。页内序号 + ←/→ 翻页是唯一能扩展的方案。

改动

src/js/wheel.js:215-227:数字键分支从 n <= PAGE 改为 /^\d$/ 全数字统一走选择:

  • 有效 → pick() 选中该花瓣
  • 超范围 → 弹 wh.keyRange toast(1.4s)提示「本页只有 {n} 项,按 1–{n} 选择」
  • 数字永不进 query(0、7-9、短页超范围键统一处理)

src/js/i18n/{zh-CN,en-US}.js:新增 wh.keyRange。

UI 决策:不加常驻文案

中心圆只有 56px,已有 1/2 页码。误按数字时弹出的 toast 恰好在困惑发生的那一刻教学规则,比常驻小字更符合「需要时出现」。

测试

新增 tests/e2e/wheel_page_keys_e2e.py(249 行,20 项),含专门抓本 bug 的断言 digit 9 does not append to query。

套件 结果
wheel_page_keys_e2e.py 20/20 ALL PASS
wheel_sort_drag_e2e.py 26/26 ALL PASS
no_tauri_e2e.py 13/13 ALL PASS
hotkey_status_e2e.py 10/10 ALL PASS
hotkey_recorder_e2e.py ALL PASS

Rust 侧未动,纯前端 fix;node --check 三个改动文件均通过。


Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Devin Review

Comment thread src/js/wheel.js Outdated
const els = $$('.petal');
if (matches[n - 1] && els[n - 1]) pick(els[n - 1], matches[n - 1]);
if (n >= 1 && matches[n - 1] && els[n - 1]) { pick(els[n - 1], matches[n - 1]); return; }
if (matches.length) toast('info', t('wh.keyRange', { n: matches.length }), 1400);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Invalid key repeats block wheel petals

Holding an invalid digit makes toast stack up to five hints across the 320-pixel wheel. The hints cover petals and intercept clicks until they expire.

Learn more

Each repeated keydown for an invalid digit creates a separate toast. The toast helper retains up to five messages for 1.4 seconds each, and the toast layout places them above the wheel's bottom edge with pointer events enabled. Several messages span the wheel's petal positions and intercept clicks even after the key is released.

Example: Hold 7 while six petals are visible. Keyboard repeat quickly creates five range hints. The hints overlap the lower petals, so clicking one hits a toast rather than selecting a prompt.

Recommended fix: Coalesce repeated wh.keyRange notifications into one visible toast, or replace and reset a single range hint. Verify that holding an invalid key leaves the petals clickable.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

回应 Devin Review on PR #18:按住超范围数字时 keydown 自动重复,
每次重复都新建一个 toast,最多叠 5 个,盖住下半花瓣并拦截点击。

- toast() 增 key 参数:同 key 的在世提示直接替换内容并重置计时器
- .toast 补 pointer-events:none(纵深防御,任何 toast 都不该拦点击)
- e2e 补 2 条断言:按住 7 只出 1 个 toast + toast 不拦截花瓣点击
- 第 8 条断言原假设「每次新增」(count 增长),改为断言提示内容正确
  (契约变了:keyed toast 是替换不是堆叠,不是放水)
@Haaaiawd

Copy link
Copy Markdown
Owner Author

已修复,见 f11e8a8。

根因:keydown 自动重复时每次重复都新建一个 toast(toast.js 无去重),最多叠 5 个;而 .toast 没设 pointer-events:none(同文件里 .tip/.empty-tip 都设了,就它漏了),所以叠起来的提示既盖住下半花瓣又拦截点击。

修法(两层):

  1. toast() 增加 key 参数——同 key 的在世提示替换内容并重置计时器,不再新建。wh.keyRange 用固定 key 'wh.keyRange',按住不放始终只有一个提示。
  2. .toast 补 pointer-events:none 作为纵深防御:任何 toast 都不该拦截点击。

测试(wheel_page_keys_e2e.py,22/22 ALL PASS)新增 2 条:

  • held out-of-range digit coalesces to one toast——按住 7 让 OS 自动重复真发 700ms,断言 #toasts .toast 恰为 1
  • toast does not intercept petal clicks——读 computed style 断言 pointer-events: none

一处契约变更说明:原第 8 条断言写的是 toast.count() > n_toasts(假设每次新增),keyed toast 是替换语义所以 count 可能不变。已改为断言提示内容正确(1–2 在 toast 文本里)且仍无注入——抓的是同一件事(误按有反馈、不误动作),不是放水。

全量回归:5 个 e2e 套件全 ALL PASS;node --check 三个改动文件通过。

@Haaaiawd
Haaaiawd merged commit b69cb49 into master Oct 18, 2026
5 checks passed
@Haaaiawd
Haaaiawd deleted the fix/wheel-page-hotkey branch October 18, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant