Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lists] Also set Value (and InternalValue) when SelectedOption is set #1970

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading