Skip to content

Commit

Permalink
[Lists] Also set Value (and InternalValue) when SelectedOption is set
Browse files Browse the repository at this point in the history
  • Loading branch information
vnbaaij authored Apr 29, 2024
1 parent 1cb7292 commit 3a0fd20
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Core/Components/List/ListComponentBase.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.FluentUI.AspNetCore.Components.Utilities;
Expand Down Expand Up @@ -62,9 +66,9 @@ protected string? InternalValue
// Raise Changed events in another thread
RaiseChangedEventsAsync().ConfigureAwait(false);
}
}
}
}
}

/// <summary>
/// Gets or sets the width of the component.
Expand Down Expand Up @@ -270,9 +274,9 @@ public override async Task SetParametersAsync(ParameterView parameters)
_currentSelectedOption = newSelectedOption;
}

Value = GetOptionValue(_currentSelectedOption);
await ValueChanged.InvokeAsync(Value);
}
Value = GetOptionValue(_currentSelectedOption);
await ValueChanged.InvokeAsync(Value);
}
else if (isSetValue && Items != null && GetOptionValue(_currentSelectedOption) != newValue)
{
newSelectedOption = Items.FirstOrDefault(item => GetOptionValue(item) == newValue);
Expand Down Expand Up @@ -336,7 +340,7 @@ protected override void OnParametersSet()
}
}

if (Value is not null && (InternalValue is null || InternalValue != Value))
if (Value is not null && (InternalValue is null || InternalValue != Value))
{
InternalValue = Value;
}
Expand Down Expand Up @@ -491,6 +495,7 @@ protected virtual async Task OnSelectedItemChangedHandlerAsync(TOption? item)
if (!Equals(item, SelectedOption))
{
SelectedOption = item;
InternalValue = Value = GetOptionValue(item);
await RaiseChangedEventsAsync();
}
}
Expand Down

0 comments on commit 3a0fd20

Please sign in to comment.