-
-
Notifications
You must be signed in to change notification settings - Fork 362
refactor(Keydown): remove NumpadEnter check #6944
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR refactors keyboard event handling by standardizing on the e.key property (removing redundant NumpadEnter and e.code checks) across multiple components, and adds a null check in the popover hide logic to prevent runtime errors. Class diagram for updated keyboard event handling in componentsclassDiagram
class AutoComplete {
+init(id, invoke, value, changedEventCallback)
handlerKeydown(ac, e)
}
class BootstrapInput {
+handleKeyUp(id, invoke, enter, enterCallbackMethod, esc, escCallbackMethod)
}
class MultiSelect {
+init(id, invoke, options)
}
class IpAddress {
+init(id)
}
class Textarea {
+init(id)
}
class base_select {
+initKeydownHandler(select)
}
AutoComplete : - NumpadEnter check removed in handlerKeydown
BootstrapInput : - NumpadEnter check removed in handleKeyUp
MultiSelect : - NumpadEnter and e.code checks removed in init
IpAddress : - e.code replaced with e.key in init
Textarea : - NumpadEnter check removed in init
base_select : - NumpadEnter check removed in initKeydownHandler
Flow diagram for popover hide logic with null checkflowchart TD
A["confirm.hide() called"] --> B["getDescribedElement(el)"]
B --> C{"popover == null?"}
C -- Yes --> D["return"]
C -- No --> E["popover.classList.remove('show')"]
E --> F["iterate popover.children"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 pull request refactors keyboard event handling to standardize on using e.key === 'Enter' instead of checking for both 'Enter' and 'NumpadEnter'. The changes also include switching from e.code to e.key for key detection and adding a null check for improved robustness.
- Removes redundant NumpadEnter checks since modern browsers treat both Enter keys the same way
- Standardizes key detection by using
e.keyinstead ofe.code - Adds null safety check in PopConfirmButton component
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/BootstrapBlazor/wwwroot/modules/base-select.js | Removes NumpadEnter check from keydown handler |
| src/BootstrapBlazor/Components/Textarea/Textarea.razor.js | Simplifies Enter key detection in keydown event |
| src/BootstrapBlazor/Components/Select/MultiSelect.razor.js | Changes from e.code to e.key and removes NumpadEnter check |
| src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js | Switches from e.code to e.key for arrow and space key detection |
| src/BootstrapBlazor/Components/Input/BootstrapInput.razor.js | Removes NumpadEnter check from keyup handler |
| src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.js | Adds null check for popover element |
| src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js | Removes NumpadEnter check from keydown handler |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Hey there - I've reviewed your changes - here's some feedback:
- Consider extracting the Enter key detection logic (
e.key === 'Enter') into a shared helper to avoid duplicating it across multiple components. - You can simplify the null popover guard in
confirm.hideby using optional chaining (getDescribedElement(el)?.classList.remove('show')). - Double-check that removing the NumpadEnter check doesn’t impact keyboard accessibility on devices that might still emit that code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider extracting the Enter key detection logic (`e.key === 'Enter'`) into a shared helper to avoid duplicating it across multiple components.
- You can simplify the null popover guard in `confirm.hide` by using optional chaining (`getDescribedElement(el)?.classList.remove('show')`).
- Double-check that removing the NumpadEnter check doesn’t impact keyboard accessibility on devices that might still emit that code.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6944 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 740 740
Lines 31875 31875
Branches 4469 4469
=========================================
Hits 31875 31875
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6943
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Refactor keydown handlers to simplify Enter key detection and fortify popover hide logic
Bug Fixes:
Enhancements: