-
Notifications
You must be signed in to change notification settings - Fork 23
fix: should not trigger onEsc when IME composing #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough在 Escape 键处理逻辑中添加了对 IME 组合状态(isComposing)的判断,防止在输入法组合期间触发 onEsc;添加对应测试并在示例中新增一个输入控件用于复现场景。 (≤50 字) Changes
Sequence Diagram(s)(本次变更为局部键盘事件处理和测试示例,交互流程简单,故未生成序列图。) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @aojunhao123, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a crucial fix to prevent unintended Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly prevents the onEsc event from firing during IME composition by checking the event.isComposing property. The change is simple, effective, and is accompanied by a new test case that properly validates the fix. The addition of an input field to the basic example is also a good touch for manual testing and demonstration. I have one minor suggestion to improve code clarity in the new test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #32 +/- ##
=======================================
Coverage 94.24% 94.24%
=======================================
Files 7 7
Lines 139 139
Branches 48 48
=======================================
Hits 131 131
Misses 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| </Portal>, | ||
| ); | ||
|
|
||
| fireEvent.keyDown(window, { key: 'Escape', isComposing: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
测试中其实无法模拟真实世界中IME的行为,这里有点脱裤子放屁的嫌疑(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
docs/examples/basic.tsx (1)
25-25: 建议移除或说明此输入框的用途。这个未绑定任何处理器的
<input>元素看起来与 IME 修复无关。如果它是为了手动测试 IME 行为而添加的,建议:
- 添加注释说明其用途
- 或者在测试完成后将其移除
否则这个孤立的输入框会让示例代码难以理解。
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs/examples/basic.tsxsrc/useEscKeyDown.tstests/index.test.tsx
🔇 Additional comments (2)
src/useEscKeyDown.ts (1)
12-12: 修复正确!添加
!event.isComposing检查能够正确防止在 IME 输入法组合期间触发onEsc回调。isComposing是标准的KeyboardEvent属性,这是解决该问题的标准做法。tests/index.test.tsx (1)
360-371: 测试用例编写正确!该测试用例正确验证了在 IME 组合状态下按下 Escape 键不会触发
onEsc回调。测试结构清晰,断言准确。
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary by CodeRabbit
发布说明
新功能
Bug修复
测试
✏️ Tip: You can customize this high-level summary in your review settings.