Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented Sep 19, 2025

Link issues

fixes #6760

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

Deprecate the OnClear callback on the Search component and consolidate clear actions into the OnSearch callback; unify clearable properties in the auto-complete base class; update styling and tests to match the new implementation.

New Features:

  • Deprecate and remove the OnClear parameter on the Search component and merge its behavior into OnSearch
  • Introduce IsClearable and ClearIcon parameters in PopoverCompleteBase to centralize clearable behavior

Bug Fixes:

  • Ensure clearing the search input invokes OnSearchClick instead of the obsolete OnClear

Enhancements:

  • Update Search and auto-complete CSS to use logical margin properties and new clear-icon color variable
  • Wrap search template icons in a dedicated wrapper and ensure input-group buttons show pointer cursors

Tests:

  • Adapt SearchTest to attach clear behavior to OnSearch and update assertions for the renamed clear-icon markup

Copilot AI review requested due to automatic review settings September 19, 2025 02:08
@bb-auto bb-auto bot added the enhancement New feature or request label Sep 19, 2025
@bb-auto bb-auto bot added this to the 9.10.0 milestone Sep 19, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 19, 2025

Reviewer's Guide

This PR streamlines clear functionality by removing the separate OnClear callback in Search (merging it into OnSearch), moves clearable parameters into the common PopoverCompleteBase, refines markup and SCSS for search clear and template icons, and updates unit tests to match the revised behavior and class names.

Sequence diagram for merged clear action in Search component

sequenceDiagram
    participant User as actor User
    participant Search as Search<TValue>
    participant JS as JSInterop
    User->>Search: Clicks clear button
    Search->>JS: setValue(Id, "")
    Search->>Search: _displayText = null
    Search->>Search: OnSearchClick()
    Search->>Search: (OnClear callback is obsolete, not called)
Loading

File-Level Changes

Change Details Files
Unify clear callback handling in Search component
  • Mark OnClear parameter obsolete and remove its invocation
  • Merge clear button logic into OnSearchClick
  • Remove redundant ClearIcon assignment in OnParametersSet
src/BootstrapBlazor/Components/Search/Search.razor.cs
Consolidate clearable parameters in common base
  • Add IsClearable and ClearIcon parameters with defaults to PopoverCompleteBase
  • Remove duplicate IsClearable/ClearIcon definitions and defaults from AutoComplete
  • Remove duplicate IsClearable/ClearIcon definitions and defaults from AutoFill
src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs
src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs
src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs
Refine search component markup and styling
  • Rename clear icon wrapper class and wrap IconTemplate in Search.razor
  • Switch margins to inline-start/end and add CSS variables
  • Add styles for search-template-icon and input-group button cursor
src/BootstrapBlazor/Components/Search/Search.razor
src/BootstrapBlazor/Components/Search/Search.razor.scss
Update unit tests for revised clear feature
  • Modify OnClearClick_Ok test to use OnSearch callback with TaskCompletionSource
  • Adjust HTML class assertion for clear icon wrapper
  • Await TaskCompletionSource in test before asserting
test/UnitTest/Components/SearchTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#6760 Remove the OnClear callback from the Search component and reuse the OnSearch callback for clear actions.

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

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 removes the deprecated OnClear callback from the Search component and consolidates its functionality with the OnSearch method. The change simplifies the API by eliminating redundant callbacks and moves clear icon properties to the base class for better component inheritance.

  • Deprecated and marked OnClear callback as obsolete in Search component
  • Moved IsClearable and ClearIcon properties from individual components to PopoverCompleteBase for inheritance
  • Updated styling to use logical properties and improved CSS class naming

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/BootstrapBlazor/Components/Search/Search.razor.cs Deprecated OnClear callback and removed duplicate property definitions
src/BootstrapBlazor/Components/Search/Search.razor Updated CSS class names and added wrapper for icon template
src/BootstrapBlazor/Components/Search/Search.razor.scss Improved CSS with logical properties and updated class selectors
src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs Added IsClearable and ClearIcon properties to base class
src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs Removed duplicate properties now inherited from base class
src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs Removed duplicate properties now inherited from base class
test/UnitTest/Components/SearchTest.cs Updated test to use OnSearch instead of deprecated OnClear

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 and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/BootstrapBlazor/Components/Search/Search.razor.scss:1` </location>
<code_context>
-.search.auto-complete {
+.search.auto-complete {
     --bb-ac-padding-right: #{$bb-search-padding-right};
</code_context>

<issue_to_address>
**issue (bug_risk):** Addition of BOM (Byte Order Mark) may cause issues in some environments.

Some compilers or tools may not handle BOMs correctly. Remove it unless absolutely necessary.
</issue_to_address>

### Comment 2
<location> `src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs:94-103` </location>
<code_context>
     [Parameter]
     public bool ShowNoDataTip { get; set; } = true;

-    /// <summary>
-    /// Gets or sets whether the select component is clearable. Default is false.
-    /// </summary>
-    [Parameter]
-    public bool IsClearable { get; set; }
-
-    /// <summary>
-    /// Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up.
-    /// </summary>
-    [Parameter]
-    [NotNull]
-    public string? ClearIcon { get; set; }
-
     /// <summary>
</code_context>

<issue_to_address>
**issue:** ClearIcon parameter is marked [NotNull] but is nullable.

Please update the ClearIcon property to either remove the [NotNull] attribute or make it non-nullable to ensure consistency and prevent possible runtime errors.
</issue_to_address>

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.

@ArgoZhang ArgoZhang merged commit 61e7c08 into main Sep 19, 2025
5 checks passed
@ArgoZhang ArgoZhang deleted the refactor-search branch September 19, 2025 02:10
@codecov
Copy link

codecov bot commented Sep 19, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #6761   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          739       739           
  Lines        31729     31718   -11     
  Branches      4466      4463    -3     
=========================================
- Hits         31729     31718   -11     
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.

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(Search): remove OnClear callback reuse OnSearch

2 participants