File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
src/CodeBeam.MudBlazor.Extensions/Components/ListExtended
tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -1083,10 +1083,13 @@ protected async Task SearchChanged(string? searchString)
10831083 {
10841084 _searchString = searchString ;
10851085
1086- var items = CollectAllMudListItems ( true ) ;
1087- foreach ( var item in items )
1086+ if ( ItemCollection == null )
10881087 {
1089- item . ApplySearch ( IsMatch ( item ) ) ;
1088+ var items = CollectAllMudListItems ( true ) ;
1089+ foreach ( var item in items )
1090+ {
1091+ item . ApplySearch ( IsMatch ( item ) ) ;
1092+ }
10901093 }
10911094
10921095 await OnSearchStringChange . InvokeAsync ( searchString ) ;
Original file line number Diff line number Diff line change @@ -337,5 +337,31 @@ public void ListColorTest(Color color)
337337 var listItemClasses = comp . Find ( ".mud-selected-item" ) ;
338338 listItemClasses . ClassList . Should ( ) . ContainInOrder ( new [ ] { $ "mud-{ color . ToDescriptionString ( ) } -text", $ "mud-{ color . ToDescriptionString ( ) } -hover" } ) ;
339339 }
340+
341+ [ Test ]
342+ public async Task List_SearchChanged_WithNullItemCollection ( )
343+ {
344+ var comp = Context . Render < ListExperimentalSelectionTest > ( ) ;
345+ var list = comp . FindComponent < MudListExtended < int > > ( ) . Instance ;
346+
347+ // Verify ItemCollection is null - items are defined in markup
348+ list . ItemCollection . Should ( ) . BeNull ( ) ;
349+
350+ // Verify initial items count from markup
351+ var initialItems = comp . FindAll ( "div.mud-list-item-extended" ) . Count ;
352+ initialItems . Should ( ) . Be ( 9 ) ; // 7 choices, 2 groups
353+
354+ // Verify we can access items via GetItems() - this calls CollectAllMudListItems internally
355+ var items = list . GetItems ( ) ;
356+ items . Should ( ) . HaveCount ( 7 ) ;
357+
358+ // Select an item to verify the list still works correctly
359+ await comp . InvokeAsync ( ( ) => list . SelectedValue = 1 ) ;
360+ comp . WaitForAssertion ( ( ) => list . SelectedItem ? . Text . Should ( ) . Be ( "Sparkling Water" ) ) ;
361+
362+ // Verify all items are still accessible
363+ var finalItems = comp . FindAll ( "div.mud-list-item-extended" ) . Count ;
364+ finalItems . Should ( ) . Be ( 9 ) ;
365+ }
340366 }
341- }
367+ }
You can’t perform that action at this time.
0 commit comments