feat(SelectSearchMetadata): add ShowSearch parameter#7796
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds 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 componentsequenceDiagram
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
Class diagram for updated SelectSearchMetadata and Select wiringclassDiagram
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
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
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:
|
There was a problem hiding this comment.
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(defaultfalse) with XML docs. - Forward
ShowSearchfromSelectSearchMetadatainto the renderedSelect<string>inISearchItemExtensions. - Update unit test setup and bump
BootstrapBlazorpackage version to10.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.
| var meta = new SelectSearchMetadata() | ||
| { | ||
| ShowSearch = true, | ||
| Items = new List<SelectedItem>() | ||
| { |
There was a problem hiding this comment.
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.
| 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(); | ||
| } |
There was a problem hiding this comment.
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.
| 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(); |
There was a problem hiding this comment.
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.
Link issues
fixes #7795
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
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:
Tests: