Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

点击焦点与空格连续触发问题 #3

Closed
LemonPrefect opened this issue Dec 18, 2022 · 1 comment
Closed

点击焦点与空格连续触发问题 #3

LemonPrefect opened this issue Dec 18, 2022 · 1 comment

Comments

@LemonPrefect
Copy link
Contributor

LemonPrefect commented Dec 18, 2022

现象:当连续点击 想一想 按钮后单击空格会导致两次词语生成。
推测:点击后焦点留在按钮上,按空格可以触发单击和按钮两个事件。
证实:

  1. 点击一次 想一想
  2. 直接按空格键
  3. 点击页面空白处
  4. 按空格键

第二步和第四步响应不同,同时焦点位置也不同。
Q.E.D

修正建议:在监听到键盘按键后判断焦点是否在按钮上,如果在则直接取消事件传播。如果不在则调用一次生成函数。

@LemonPrefect
Copy link
Contributor Author

LemonPrefect commented Dec 18, 2022

更新:当焦点位于 Shuffle 按键处,空格将会导致 inspire 和 shuffle 同时触发。
补充:测试环境:Chrome Dev 110.0.5478.4/Windows 10。
修正建议:禁止按钮焦点停留。取消默认按键触发。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants