Skip to content

Commit

Permalink
[ListComponentBase] Fix #3029 invoke ValueChanged when initially se…
Browse files Browse the repository at this point in the history
…lecting an option (#3105)

* fix #3029 invoke `ValueChanged` when initially selecting an option

* Check the Value before raising the ValueChanged #3105

---------

Co-authored-by: La Minh Phuc <[email protected]>
  • Loading branch information
pk9r and pk9r authored Dec 27, 2024
1 parent eb5cd26 commit 75b8f5f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Core/Components/List/ListComponentBase.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,15 @@ protected override void OnParametersSet()
{
if (SelectedOption == null && Items != null && OptionSelected != null)
{
TOption? item = Items.FirstOrDefault(i => OptionSelected.Invoke(i));
InternalValue = GetOptionValue(item);
var item = Items.FirstOrDefault(i => OptionSelected.Invoke(i));
var value = GetOptionValue(item);
InternalValue = value;
if (value != Value && ValueChanged.HasDelegate)
{
ValueChanged.InvokeAsync(value);
}
}
}

}

/// <inheritdoc />
Expand Down

0 comments on commit 75b8f5f

Please sign in to comment.