-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix] Ensure key down targeting works for elements in Shadow DOM #13264
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
[fix] Ensure key down targeting works for elements in Shadow DOM #13264
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.
Pull request overview
This PR fixes keyboard shortcut handling to prevent accidental triggering of global single-key shortcuts (like "c", "r", and "a") when users are typing in editable elements, including those inside Shadow DOM trees.
Key Changes:
- Adds Shadow DOM-aware detection of editable elements via
composedPath()inspection - Exports new helper function
isKeyboardEventFromEditableTargetfor app-level and widget-level shortcut suppression - Updates App and StatusWidget keyboard handlers to respect editable contexts
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
frontend/lib/src/hooks/useRegisterShortcut.ts |
Implements getEditableEventTarget to detect editable elements in Shadow DOM by inspecting composedPath(), and exports isKeyboardEventFromEditableTarget helper function. Updates filter and blocking logic to use the new Shadow DOM-aware detection. |
frontend/lib/src/index.ts |
Exports the new isKeyboardEventFromEditableTarget helper for use in app components. |
frontend/lib/src/hooks/useRegisterShortcut.test.tsx |
Adds comprehensive tests for Shadow DOM scenarios, verifying that shortcuts are correctly blocked when typing in inputs inside shadow roots. |
frontend/app/src/App.tsx |
Updates handleKeyDown to accept optional KeyboardEvent parameter and suppress "c"/"r" shortcuts when user is typing in editable elements (including Shadow DOM). |
frontend/app/src/components/StatusWidget/StatusWidget.tsx |
Updates handleKeyDown to accept optional KeyboardEvent parameter and suppress "a" shortcut when user is typing in editable elements (including Shadow DOM). |
📈 Frontend coverage change detectedThe frontend unit test (vitest) coverage has increased by 0.0900%
🎉 Great job on improving test coverage! |
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
fffb611 to
b4e286d
Compare
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
|
@cursor review |
SummaryThis PR fixes an issue where keyboard shortcuts were incorrectly triggering (or failing to be suppressed) when the user was interacting with an editable element inside a Shadow DOM. It introduces a Code QualityThe code is clean, well-structured, and follows the project's TypeScript conventions.
Test Coverage
Backwards CompatibilityThe changes are backwards compatible. The Security & Risk
RecommendationsNo changes requested. The implementation is solid. VerdictAPPROVED: The PR correctly addresses the Shadow DOM event targeting issue with robust logic and excellent unit test coverage. |
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.
✅ Bugbot reviewed your changes and found no bugs!
lukasmasuch
left a 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.
LGTM 👍
) ## Describe your changes - Improves the handling of keyboard shortcuts to prevent accidental triggering of global single-key shortcuts (like "c", "r", and "a") when the user is typing in editable elements, including those inside Shadow DOM. - Ensures that shortcuts are suppressed in appropriate contexts across both app-level and widget-level handlers. ## GitHub Issue Link (if applicable) ## Testing Plan - Adds unit tests --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Describe your changes
GitHub Issue Link (if applicable)
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.