File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed
src/BootstrapBlazor/Components/Select Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -175,17 +175,7 @@ private SelectedItem? SelectedRow
175175 return null ;
176176 }
177177
178- if ( IsVirtualize )
179- {
180- _init = false ;
181- return new SelectedItem ( CurrentValueAsString , DefaultVirtualizeItemText ?? CurrentValueAsString ) ;
182- }
183-
184- var item = GetItemWithEnumValue ( )
185- ?? Rows . Find ( i => i . Value == CurrentValueAsString )
186- ?? Rows . Find ( i => i . Active )
187- ?? Rows . FirstOrDefault ( i => ! i . IsDisabled ) ;
188-
178+ var item = IsVirtualize ? GetItemByVirtulized ( ) : GetItemByRows ( ) ;
189179 if ( item != null )
190180 {
191181 if ( _init && DisableItemChangedWhenFirstRender )
@@ -201,9 +191,18 @@ private SelectedItem? SelectedRow
201191 return item ;
202192 }
203193
204- private SelectedItem ? GetItemWithEnumValue ( ) => ValueType . IsEnum
205- ? Rows . Find ( i => i . Value == Convert . ToInt32 ( Value ) . ToString ( ) )
206- : null ;
194+ private SelectedItem ? GetItemWithEnumValue ( ) => ValueType . IsEnum ? Rows . Find ( i => i . Value == Convert . ToInt32 ( Value ) . ToString ( ) ) : null ;
195+
196+ private SelectedItem GetItemByVirtulized ( ) => new ( CurrentValueAsString , DefaultVirtualizeItemText ?? CurrentValueAsString ) ;
197+
198+ private SelectedItem ? GetItemByRows ( )
199+ {
200+ var item = GetItemWithEnumValue ( )
201+ ?? Rows . Find ( i => i . Value == CurrentValueAsString )
202+ ?? Rows . Find ( i => i . Active )
203+ ?? Rows . FirstOrDefault ( i => ! i . IsDisabled ) ;
204+ return item ;
205+ }
207206
208207 /// <summary>
209208 /// <inheritdoc/>
You can’t perform that action at this time.
0 commit comments