Skip to content

Commit bd5e3ab

Browse files
committed
Revert "refactor: 精简代码"
This reverts commit 114d3ad.
1 parent 114d3ad commit bd5e3ab

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/BootstrapBlazor/Components/Select/Select.razor.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,17 @@ private SelectedItem? SelectedRow
266266
?? Rows.Where(i => !i.IsDisabled).FirstOrDefault()
267267
?? GetVirtualizeItem(CurrentValueAsString);
268268

269-
if (_init && DisableItemChangedWhenFirstRender)
269+
if (item != null)
270270
{
271+
if (_init && DisableItemChangedWhenFirstRender)
272+
{
271273

272-
}
273-
else
274-
{
275-
_ = SelectedItemChanged(item);
276-
_init = false;
274+
}
275+
else
276+
{
277+
_ = SelectedItemChanged(item);
278+
_init = false;
279+
}
277280
}
278281
return item;
279282
}
@@ -377,12 +380,12 @@ private bool TryParseSelectItem(string value, [MaybeNullWhen(false)] out TValue
377380
?? GetVirtualizeItem(value);
378381

379382
// support SelectedItem? type
380-
result = (TValue)(object)SelectedItem;
383+
result = SelectedItem != null ? (TValue)(object)SelectedItem : default;
381384
validationErrorMessage = "";
382385
return SelectedItem != null;
383386
}
384387

385-
private SelectedItem GetVirtualizeItem(string value)
388+
private SelectedItem? GetVirtualizeItem(string value)
386389
{
387390
SelectedItem? item = null;
388391
if (_result.Items != null)

0 commit comments

Comments
 (0)