Skip to content

feat(SelectSearchMetadata): add ShowSearch parameter#7796

Merged
ArgoZhang merged 4 commits intomainfrom
feat-search-item
Mar 24, 2026
Merged

feat(SelectSearchMetadata): add ShowSearch parameter#7796
ArgoZhang merged 4 commits intomainfrom
feat-search-item

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Mar 24, 2026

Link issues

fixes #7795

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

Add support for toggling the visibility of the search box in select-based search metadata and propagate the setting to the Select component.

New Features:

  • Introduce a ShowSearch option on SelectSearchMetadata to control whether the associated select search field displays a search box.

Tests:

  • Extend SelectSearchMetadata unit test coverage to verify the ShowSearch option behavior.

Copilot AI review requested due to automatic review settings March 24, 2026 04:00
@bb-auto bb-auto bot added the enhancement New feature or request label Mar 24, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 24, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a configurable ShowSearch option to SelectSearchMetadata and wires it through to the Select component, along with a unit test to cover the new metadata property.

Sequence diagram for applying ShowSearch from metadata to Select component

sequenceDiagram
    participant SearchForm
    participant ISearchItemExtensions
    participant Select_generic as Select

    SearchForm->>ISearchItemExtensions: AddSelectSearchComponent(item, selectSearchMetadata)
    ISearchItemExtensions->>Select: Build component
    ISearchItemExtensions->>Select: Set Items = selectSearchMetadata.Items
    ISearchItemExtensions->>Select: Set PlaceHolder = selectSearchMetadata.PlaceHolder
    ISearchItemExtensions->>Select: Set SkipValidate = true
    ISearchItemExtensions->>Select: Set ShowSearch = selectSearchMetadata.ShowSearch
    Select-->>SearchForm: Rendered select with search box visibility based on ShowSearch
Loading

Class diagram for updated SelectSearchMetadata and Select wiring

classDiagram
    class StringSearchMetadata

    class SelectSearchMetadata {
        bool ShowSearch
        object Items
        string PlaceHolder
    }

    class Select_generic {
        bool ShowSearch
        object Items
        string PlaceHolder
        bool SkipValidate
    }

    class ISearchItemExtensions {
        void AddSelectSearchComponent(ISearchItem item, SelectSearchMetadata selectSearchMetadata)
    }

    class ISearchItem

    StringSearchMetadata <|-- SelectSearchMetadata
    ISearchItemExtensions ..> ISearchItem : uses
    ISearchItemExtensions ..> SelectSearchMetadata : uses
    ISearchItemExtensions ..> Select_generic : configures
Loading

File-Level Changes

Change Details Files
Introduce ShowSearch flag on select search metadata and pass it to the Select component.
  • Add a ShowSearch boolean property to SelectSearchMetadata with XML documentation in both Chinese and English, defaulting to false.
  • Bind the SelectSearchMetadata.ShowSearch value to the Select component by adding a ShowSearch attribute in the AddSelectSearchComponent builder.
  • Extend the SelectSearchFormItemMetadata_Ok unit test to set ShowSearch to true, ensuring the property is exercised in tests.
src/BootstrapBlazor/Components/Searches/SelectSearchMetadata.cs
src/BootstrapBlazor/Extensions/ISearchItemExtensions.cs
test/UnitTest/Components/SearchFormItemMetadataTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#7795 Add a ShowSearch parameter/property to SelectSearchMetadata to control whether the search box is shown.
#7795 Wire the ShowSearch parameter through to the rendered Select component (and cover it with tests or usage) so that it affects runtime behavior.

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

@bb-auto bb-auto bot added this to the v10.4.0 milestone Mar 24, 2026
@ArgoZhang ArgoZhang merged commit 5270336 into main Mar 24, 2026
6 checks passed
@ArgoZhang ArgoZhang deleted the feat-search-item branch March 24, 2026 04:00
Copy link
Copy Markdown
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 reviewed your changes and they look great!


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
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7796   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          764       764           
  Lines        34109     34111    +2     
  Branches      4697      4697           
=========================================
+ Hits         34109     34111    +2     
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
Copy Markdown
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

Adds a ShowSearch switch to SelectSearchMetadata so SearchForm can optionally render Select’s built-in dropdown search box when using select-based search metadata (fixes #7795).

Changes:

  • Introduce SelectSearchMetadata.ShowSearch (default false) with XML docs.
  • Forward ShowSearch from SelectSearchMetadata into the rendered Select<string> in ISearchItemExtensions.
  • Update unit test setup and bump BootstrapBlazor package version to 10.5.0-beta01.

Reviewed changes

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

File Description
test/UnitTest/Components/SearchFormItemMetadataTest.cs Sets ShowSearch = true in SelectSearchMetadata test setup.
src/BootstrapBlazor/Extensions/ISearchItemExtensions.cs Passes ShowSearch into the Select<> component during SearchForm item rendering.
src/BootstrapBlazor/Components/Searches/SelectSearchMetadata.cs Adds ShowSearch property with bilingual XML documentation.
src/BootstrapBlazor/BootstrapBlazor.csproj Updates package version to 10.5.0-beta01.

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

Comment on lines 108 to 112
var meta = new SelectSearchMetadata()
{
ShowSearch = true,
Items = new List<SelectedItem>()
{
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

ShowSearch = true is set here but never asserted, so the test doesn't actually validate any behavior change (it only compiles). Consider asserting meta.ShowSearch (at minimum), or moving coverage to a bUnit render test (e.g., in SearchFormTest) that verifies the Select dropdown renders the search input when ShowSearch is enabled.

Copilot uses AI. Check for mistakes.
Comment on lines 154 to 165
builder.OpenComponent<Select<string>>(0);
builder.AddAttribute(10, nameof(Select<>.Value), selectSearchMetadata.Value);
builder.AddAttribute(20, nameof(Select<>.OnValueChanged), selectSearchMetadata.ValueChangedHandler);
builder.AddAttribute(30, nameof(Select<>.ShowLabel), item.ShowLabel ?? true);
builder.AddAttribute(40, nameof(Select<>.ShowLabelTooltip), item.ShowLabelTooltip);
builder.AddAttribute(50, nameof(Select<>.DisplayText), item.Text);
builder.AddAttribute(60, nameof(Select<>.Items), selectSearchMetadata.Items);
builder.AddAttribute(70, nameof(Select<>.PlaceHolder), selectSearchMetadata.PlaceHolder);
builder.AddAttribute(80, nameof(Select<>.SkipValidate), true);
builder.AddAttribute(90, nameof(Select<>.ShowSearch), selectSearchMetadata.ShowSearch);
builder.CloseComponent();
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

SelectSearchMetadata is also the base type for MultipleSelectSearchMetadata, but only the single-select path forwards ShowSearch into the rendered component. This makes ShowSearch ineffective for multi-select search items. Either forward multipleSelectSearchMetadata.ShowSearch to MultiSelect<>.ShowSearch as well, or move/rename the property so it only applies to single-select metadata.

Copilot uses AI. Check for mistakes.
Comment on lines 152 to 164
private void AddSelectSearchComponent(ISearchItem item, SelectSearchMetadata selectSearchMetadata)
{
builder.OpenComponent<Select<string>>(0);
builder.AddAttribute(10, nameof(Select<>.Value), selectSearchMetadata.Value);
builder.AddAttribute(20, nameof(Select<>.OnValueChanged), selectSearchMetadata.ValueChangedHandler);
builder.AddAttribute(30, nameof(Select<>.ShowLabel), item.ShowLabel ?? true);
builder.AddAttribute(40, nameof(Select<>.ShowLabelTooltip), item.ShowLabelTooltip);
builder.AddAttribute(50, nameof(Select<>.DisplayText), item.Text);
builder.AddAttribute(60, nameof(Select<>.Items), selectSearchMetadata.Items);
builder.AddAttribute(70, nameof(Select<>.PlaceHolder), selectSearchMetadata.PlaceHolder);
builder.AddAttribute(80, nameof(Select<>.SkipValidate), true);
builder.AddAttribute(90, nameof(Select<>.ShowSearch), selectSearchMetadata.ShowSearch);
builder.CloseComponent();
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This change introduces new UI behavior (controlling whether <Select> renders its .dropdown-menu-search block) but there is no test exercising the rendering path. Since SearchFormTest already uses bUnit, consider adding a test that renders a SearchForm item with SelectSearchMetadata { ShowSearch = true } and asserts the search input is present, and another with the default (false) asserting it is absent.

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(SelectSearchMetadata): add ShowSearch parameter

2 participants