-
-
Notifications
You must be signed in to change notification settings - Fork 486
Don't open select on browser hotkeys #1191
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
Don't open select on browser hotkeys #1191
Conversation
|
@justanotheranonymoususer is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
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该 PR 修改了 Select 组件的键盘交互与测试:限制只有在按下有效 open-key 且未同时按下任何修饰键(Ctrl、Alt、Meta)时才打开下拉,同时新增相应单元测试并扩展测试工具的 keyDown 选项参数以支持传入修饰键信息。 Changes
Sequence Diagram(s)(无;变更为单文件与测试相关的小范围键盘事件判断与测试工具扩展,不满足生成序列图的条件。) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code graph analysis (1)tests/Select.test.tsx (1)
🔇 Additional comments (2)
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 @justanotheranonymoususer, 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 addresses an issue where the 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 select dropdown from opening when browser hotkeys like Ctrl+F are used. The change is a good fix for the described issue. I've added a comment with a suggestion to slightly improve readability and to add a test case to prevent future regressions of this behavior.
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 (2)
src/SelectInput/index.tsx (2)
150-150: 可选:考虑是否需要检查 shiftKey。当前实现未检查
event.shiftKey,这可能是有意为之(例如 Shift+字母用于输入大写字母时应该打开下拉菜单)。但如果某些 Shift 组合键(如 Shift+方向键)不应触发打开,可以考虑添加更精细的控制。如需添加,可参考:
-if (!event.ctrlKey && !event.altKey && !event.metaKey && isValidateOpenKey(which)) { +if (!event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && isValidateOpenKey(which)) {注意:这可能会影响正常的 Shift+字母输入行为,请谨慎评估是否需要此更改。
150-152: 修复方案有效,正确防止浏览器快捷键触发下拉菜单打开。添加修饰键检查(
!event.ctrlKey && !event.altKey && !event.metaKey)可以防止 Ctrl+F、Ctrl+S 等浏览器快捷键触发下拉菜单打开。虽然isValidateOpenKey()已排除单独的修饰键按码,但它无法阻止修饰键与字母组合(如 Ctrl+F)的情况,因为字母键本身会通过验证。新增的事件修饰符属性检查弥补了这一空隙,实现简洁且符合预期。
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/SelectInput/index.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/SelectInput/index.tsx (1)
src/utils/keyUtil.ts (1)
isValidateOpenKey(4-45)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1191 +/- ##
=======================================
Coverage 99.42% 99.42%
=======================================
Files 31 31
Lines 1216 1217 +1
Branches 433 434 +1
=======================================
+ Hits 1209 1210 +1
Misses 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Right now, if focused, it's being opened on hotkeys like Ctrl+F to search, Ctrl+S to save page, etc.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.