Skip to content

feat(Table): use Enter/EscCallbck instead of keyup event#7672

Merged
ArgoZhang merged 7 commits intomainfrom
fix-table
Feb 15, 2026
Merged

feat(Table): use Enter/EscCallbck instead of keyup event#7672
ArgoZhang merged 7 commits intomainfrom
fix-table

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Feb 15, 2026

Link issues

fixes #7671

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

Switch table search input handling to use BootstrapInput Enter/Esc callbacks instead of raw keyup events and clarify related search parameter docs.

New Features:

  • Trigger table search execution and reset via dedicated Enter and Esc callbacks on the search input.

Bug Fixes:

  • Ensure Escape in the search box properly clears search text and invokes the reset search logic via the new callback mechanism.

Enhancements:

  • Update table search input bindings to bypass validation during typing while supporting optional auto-search on input.
  • Refine XML documentation for auto-search behavior and reset search button to better describe their behavior.

Tests:

  • Adjust table search keyboard interaction tests to call the new BootstrapInput Enter/Esc callbacks instead of simulating keyup events.

Copilot AI review requested due to automatic review settings February 15, 2026 01:58
@bb-auto bb-auto bot added the enhancement New feature or request label Feb 15, 2026
@bb-auto bb-auto bot added this to the v10.3.0 milestone Feb 15, 2026
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 15, 2026

Reviewer's Guide

Refactors the Table search input to use BootstrapInput’s Enter/Esc async callbacks instead of low-level keyup and value-changed handlers, updates the corresponding event wiring in the .razor markup, and adjusts unit tests and documentation comments accordingly.

Sequence diagram for table search using Enter and Esc callbacks

sequenceDiagram
    actor User
    participant BootstrapInput
    participant Table

    User->>BootstrapInput: Type characters
    BootstrapInput-->>Table: Bind Value to SearchText (UseInputEvent, AutoSearchOnInput)

    User->>BootstrapInput: Press Enter
    BootstrapInput->>Table: OnEnterAsync(currentValue)
    Table->>Table: SearchText = currentValue
    Table->>Table: SearchClick()
    Table->>Table: QueryAsync()

    User->>BootstrapInput: Press Esc
    BootstrapInput->>Table: OnEscAsync(currentValue)
    Table->>Table: SearchText = null
    Table->>Table: ResetSearchClick()
    Table->>Table: SearchClick()
    Table-->>BootstrapInput: Updated bound items
Loading

Updated class diagram for Table search and BootstrapInput callbacks

classDiagram
    class Table_TItem_ {
        +bool AutoSearchOnInput
        +string SearchText
        +Task SearchClick()
        +Task ResetSearchClick()
        +Task ClearSearchClick()
        +Task OnEnterAsync(string v)
        +Task OnEscAsync(string v)
    }

    class BootstrapInput {
        +string Value
        +bool SkipValidate
        +bool UseInputEvent
        +Func~string,Task~ OnEnterAsync
        +Func~string,Task~ OnEscAsync
        +Func~string,Task~ OnValueChanged
    }

    Table_TItem_ --> BootstrapInput : uses_callbacks
Loading

File-Level Changes

Change Details Files
Replace keyup and value-changed handlers with Enter/Esc async callbacks for the table search box.
  • Remove dependency on KeyboardEventArgs and the OnSearchKeyUp/OnSearchTextValueChanged methods.
  • Add OnEnterAsync and OnEscAsync handlers that update SearchText and delegate to SearchClick/ResetSearchClick.
  • Ensure ResetSearchClick continues to toggle loading and now reuses SearchClick for query execution.
src/BootstrapBlazor/Components/Table/Table.razor.Search.cs
Rewire BootstrapInput in the Table toolbar to use the new Enter/Esc callbacks and adjust validation behavior.
  • Remove @onkeyup and OnValueChanged bindings from search BootstrapInput instances.
  • Bind OnEnterAsync/OnEscAsync to the new handlers and set SkipValidate="true" consistently.
  • Keep Value bound to SearchText and preserve AutoSearchOnInput usage and tooltip variants.
src/BootstrapBlazor/Components/Table/Table.razor
Update unit tests to invoke the new Enter/Esc callbacks instead of simulating keyboard events.
  • Locate the search BootstrapInput instance via component search rather than CSS-only lookup.
  • Call EnterCallback and EscCallback on the BootstrapInput instance to simulate user pressing Enter and Escape.
  • Retain assertion that reset search logic is invoked.
test/UnitTest/Components/TableTest.cs
Clarify documentation for the AutoSearchOnInput parameter.
  • Update XML doc comments to more clearly describe auto-search behavior for the fuzzy search bar in both Chinese and English.
  • Keep the parameter name and default behavior unchanged.
src/BootstrapBlazor/Components/Table/Table.razor.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7671 Update the Table search input to use BootstrapInput Enter/Esc callbacks (EnterCallback/EscCallback via OnEnterAsync/OnEscAsync) instead of handling keyup keyboard events directly.

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 b6272ee into main Feb 15, 2026
8 checks passed
@ArgoZhang ArgoZhang deleted the fix-table branch February 15, 2026 01:58
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 - I've left some high level feedback:

  • In OnEscAsync you’re manually setting SearchText and calling ResetSearchClick, which bypasses the existing ClearSearchClick method; consider delegating to ClearSearchClick instead so that any additional clear-related behavior remains centralized and consistent.
  • The updated unit test locates the search input via FindComponents<BootstrapInput<string?>>().FirstOrDefault(i => i.Markup.Contains("table-toolbar-search")), which couples the test to the rendered markup string; if possible, prefer a more stable selector (e.g., a specific attribute or known position in the toolbar) to reduce brittleness to cosmetic markup changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `OnEscAsync` you’re manually setting `SearchText` and calling `ResetSearchClick`, which bypasses the existing `ClearSearchClick` method; consider delegating to `ClearSearchClick` instead so that any additional clear-related behavior remains centralized and consistent.
- The updated unit test locates the search input via `FindComponents<BootstrapInput<string?>>().FirstOrDefault(i => i.Markup.Contains("table-toolbar-search"))`, which couples the test to the rendered markup string; if possible, prefer a more stable selector (e.g., a specific attribute or known position in the toolbar) to reduce brittleness to cosmetic markup changes.

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 Feb 15, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7672   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          749       749           
  Lines        33199     33192    -7     
  Branches      4605      4603    -2     
=========================================
- Hits         33199     33192    -7     
Flag Coverage Δ
BB 100.00% <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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 PR modernizes the Table component's search input keyboard handling by replacing the low-level @onkeyup event handler with the higher-level OnEnterAsync and OnEscAsync callbacks provided by BootstrapInput. This change aims to use a more idiomatic approach for handling keyboard interactions in the component.

Changes:

  • Replaced @onkeyup and OnValueChanged handlers with OnEnterAsync and OnEscAsync callbacks in all Table search inputs
  • Removed the OnSearchKeyUp and OnSearchTextValueChanged methods from Table.razor.Search.cs
  • Added new OnEnterAsync and OnEscAsync methods to handle Enter and Escape key presses
  • Refactored ResetSearchClick to call SearchClick for consistency
  • Updated test to use the new callback mechanism instead of simulating keyboard events
  • Improved documentation comments for better clarity

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/BootstrapBlazor/Components/Table/Table.razor Updated all 4 BootstrapInput instances to use OnEnterAsync/OnEscAsync callbacks instead of @onkeyup; added missing ShowLabel="false" attribute
src/BootstrapBlazor/Components/Table/Table.razor.cs Improved documentation comment for AutoSearchOnInput parameter
src/BootstrapBlazor/Components/Table/Table.razor.Search.cs Removed keyboard event handler methods, added new Enter/Esc callback methods, refactored ResetSearchClick for consistency
test/UnitTest/Components/TableTest.cs Updated test to invoke EnterCallback/EscCallback directly instead of simulating keyboard events

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1053 to +1054
Value="@SearchText"
OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync"
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue: missing two-way binding for the Value parameter. The SearchText property will not be updated as the user types, breaking the AutoSearchOnInput feature. Add @bind-Value="@SearchText" instead of just Value="@SearchText", or add ValueChanged="@((string? v) => SearchText = v)".

Copilot uses AI. Check for mistakes.
Comment on lines +1062 to +1063
Value="@SearchText"
OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync"
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue: missing two-way binding for the Value parameter. The SearchText property will not be updated as the user types, breaking the AutoSearchOnInput feature. Add @bind-Value="@SearchText" instead of just Value="@SearchText", or add ValueChanged="@((string? v) => SearchText = v)".

Copilot uses AI. Check for mistakes.
await cut.InvokeAsync(() => searchBox.KeyUp(new KeyboardEventArgs() { Key = "Escape" }));
await cut.InvokeAsync(() => searchBox.Change("0"));
var searchBox = cut.FindComponents<BootstrapInput<string?>>().FirstOrDefault(i => i.Markup.Contains("table-toolbar-search"));
Assert.NotNull(searchBox);
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test no longer verifies that typing in the search box updates the SearchText property. The removed line searchBox.Change("0") was testing value updates through user input. While the new test verifies the EnterCallback and EscCallback work, it doesn't test the core functionality of the search box accepting and propagating user input. Consider adding a test that verifies SearchText is updated when the user types in the search box, not just when Enter/Esc keys are pressed.

Suggested change
Assert.NotNull(searchBox);
Assert.NotNull(searchBox);
// Simulate user typing in the search box and verify that the table's SearchText is updated
searchBox.Change("0");
var table = cut.FindComponent<Table<Foo>>();
Assert.Equal("0", table.Instance.SearchText);

Copilot uses AI. Check for mistakes.
Comment on lines +200 to +201
Value="@SearchText" SkipValidate="true"
OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync"
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BootstrapInput component is missing two-way binding for the Value parameter. Currently only Value="@SearchText" is set, but there's no ValueChanged handler or @bind-Value directive. This means the SearchText property will not be updated as the user types in the search box, breaking the AutoSearchOnInput feature when UseInputEvent is set to AutoSearchOnInput (true).

The OnEnterAsync and OnEscAsync callbacks only update SearchText when Enter or Esc keys are pressed, but not during regular typing. To fix this, either:

  1. Add @bind-Value="@SearchText" instead of just Value="@SearchText", OR
  2. Add ValueChanged="@((string? v) => SearchText = v)" to handle value updates

Copilot uses AI. Check for mistakes.
Comment on lines +209 to +210
Value="@SearchText" SkipValidate="true"
OnEnterAsync="OnEnterAsync" OnEscAsync="OnEscAsync"
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the first BootstrapInput instance: missing two-way binding for the Value parameter. The SearchText property will not be updated as the user types, breaking the AutoSearchOnInput feature. Add @bind-Value="@SearchText" instead of just Value="@SearchText", or add ValueChanged="@((string? v) => SearchText = v)".

Copilot uses AI. Check for mistakes.
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.

feat(Table): use Enter/EscCallbck instead of keyup event

1 participant