Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Oct 18, 2025

Link issues

fixes #6943

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Refactor keydown handlers to simplify Enter key detection and fortify popover hide logic

Bug Fixes:

  • Prevent runtime error in PopConfirmButton.hide by checking for null popover before manipulating its classes

Enhancements:

  • Unify keyboard event handling by using e.key instead of e.code and remove redundant NumpadEnter checks across components

Copilot AI review requested due to automatic review settings October 18, 2025 10:33
@bb-auto bb-auto bot added the enhancement New feature or request label Oct 18, 2025
@bb-auto bb-auto bot added this to the 9.11.0 milestone Oct 18, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 18, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This 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 components

classDiagram
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
Loading

Flow diagram for popover hide logic with null check

flowchart 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"]
Loading

File-Level Changes

Change Details Files
Add null guard in popover hide to prevent errors when element is missing
  • Insert early return if popover is null in confirm.hide
src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.js
Use e.key instead of e.code for navigation keys
  • Replace e.code with e.key for Space and ArrowRight when at cell end
  • Replace e.code with e.key for ArrowLeft when at cell start
src/BootstrapBlazor/Components/IpAddress/IpAddress.razor.js
Remove NumpadEnter checks and rely solely on 'Enter' key in selection and input components
  • MultiSelect: use e.key 'Space' and 'Enter' only, drop e.code and NumPadEnter
  • AutoComplete: drop NumpadEnter branch, check only for 'Enter'
  • BootstrapInput: remove NumpadEnter condition and use only e.key 'Enter'
  • Textarea: remove NumpadEnter check, rely on e.key 'Enter'
  • base-select: eliminate NumpadEnter branch, handle only 'Enter'
src/BootstrapBlazor/Components/Select/MultiSelect.razor.js
src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js
src/BootstrapBlazor/Components/Input/BootstrapInput.razor.js
src/BootstrapBlazor/Components/Textarea/Textarea.razor.js
src/BootstrapBlazor/wwwroot/modules/base-select.js

Assessment against linked issues

Issue Objective Addressed Explanation
#6943 Remove all checks for 'NumpadEnter' in keydown event handling code.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 5002470 into main Oct 18, 2025
4 of 5 checks passed
@ArgoZhang ArgoZhang deleted the refactor-key branch October 18, 2025 10:33
Copy link
Contributor

Copilot AI left a 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.key instead of e.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.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a 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.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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented Oct 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (d080648) to head (1f3ab3b).
⚠️ Report is 1 commits behind head on main.

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           
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(Keydown): remove NumpadEnter check

2 participants