修复:防止“词典”快捷键触发拼写错误#284
Open
sssseaman wants to merge 1 commit into
Open
Conversation
fix: prevent collect popover shortcuts from typing
|
@sssseaman is attempting to deploy a commit to the zyronon's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
在单词练习时,按
Enter可以打开“收藏到词典”的选择弹窗。弹窗支持使用数字快捷键(1、2、3等)选择具体词典。但目前这些数字按键会先被全局打字监听器处理,再被词典弹窗处理。因此按数字选择词典时,数字也可能被录入到单词拼写输入中,导致触发拼写错误。
复现方式
Enter打开“收藏到词典”弹窗。1、2或3选择目标词典。原因
全局键盘监听器注册在
window的捕获阶段,而词典弹窗的键盘监听器注册在document的捕获阶段。由于
window捕获阶段会先执行,数字键会先被派发到练习打字逻辑中,词典弹窗再拦截时已经来不及了。解决方案
当“收藏到词典”弹窗可见时,全局练习键盘监听器跳过
keydown和keyup事件处理。这样弹窗打开期间,键盘事件由弹窗自己处理,包括:
1-9选择词典Escape关闭弹窗弹窗关闭后,全局打字输入和练习快捷键会恢复正常。
验证
packages/core/src/hooks/event.ts。..\..\node_modules\.bin\nuxt.CMD build