-
Notifications
You must be signed in to change notification settings - Fork 708
Prevent keyboard shortcuts from firing while typing in quick chat search #2528
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
base: main
Are you sure you want to change the base?
Conversation
|
|
WalkthroughModified keyboard event handlers to add early-return guards that prevent global keybinds from triggering when focus is within text input elements (input fields, textareas, or contenteditable regions). The Escape key remains actionable in all contexts. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (3 passed)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
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)
src/client/InputHandler.ts (1)
293-300: Consider extracting the text input check to reduce duplication.The same text input detection logic appears in both keydown and keyup handlers. Extract it to a helper method for cleaner code.
Add this helper method after line 625:
private isTextInput(target: EventTarget | null): boolean { const element = target as HTMLElement | null; return ( element?.tagName === "INPUT" || element?.tagName === "TEXTAREA" || element?.isContentEditable === true ); }Then simplify both guards:
window.addEventListener("keydown", (e) => { - const target = e.target as HTMLElement | null; - const isTextInput = - target?.tagName === "INPUT" || - target?.tagName === "TEXTAREA" || - target?.isContentEditable; - if (isTextInput && e.code !== "Escape") { + if (this.isTextInput(e.target) && e.code !== "Escape") { return; }window.addEventListener("keyup", (e) => { - const target = e.target as HTMLElement | null; - const isTextInput = - target?.tagName === "INPUT" || - target?.tagName === "TEXTAREA" || - target?.isContentEditable; - if (isTextInput && !this.activeKeys.has(e.code)) { + if (this.isTextInput(e.target) && !this.activeKeys.has(e.code)) { return; }Also applies to: 343-350
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/client/InputHandler.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/client/InputHandler.ts (4)
src/core/execution/NukeExecution.ts (1)
target(43-45)src/core/game/GameImpl.ts (1)
target(592-598)src/core/game/PlayerImpl.ts (1)
target(531-534)src/core/game/AttackImpl.ts (1)
target(26-28)
🔇 Additional comments (2)
src/client/InputHandler.ts (2)
293-300: LGTM! Keydown guard works correctly.The guard properly blocks shortcuts when typing in text inputs while preserving Escape functionality. This ensures players can close dialogs even when a text field has focus.
343-350: LGTM! Keyup guard maintains proper key state.The
activeKeyscheck correctly handles the edge case where a key is pressed outside a text input and released inside it, ensuring the key state is properly cleaned up.
Description:
Guard global keydown/keyup handlers to ignore events from text/textarea/contenteditable targets (except Escape/active keys) so
gameplay shortcuts don’t trigger while typing in the quick chat player search.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
aotumuri