Skip to content

Commit c19e90c

Browse files
authored
[Combobox] Fix binding to a value not in the list items
When getting the combobox content, the `Value` should be returned instead of `null`. If no `Value` has been set, `null` will still be returned.
1 parent 13fac20 commit c19e90c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

examples/Demo/Shared/Microsoft.FluentUI.AspNetCore.Components.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,14 @@
17941794
<member name="P:Microsoft.FluentUI.AspNetCore.Components.SelectColumn`1.SortBy">
17951795
<inheritdoc />
17961796
</member>
1797+
<member name="P:Microsoft.FluentUI.AspNetCore.Components.SelectColumn`1.Comparer">
1798+
<summary>
1799+
Gets or sets the equality comparer used to determine whether two grid items are equal.
1800+
</summary>
1801+
<remarks>If not set, the default equality comparer for <typeparamref name="TGridItem"/> is used.
1802+
Setting this property allows customization of how grid items are compared for equality, which can affect
1803+
operations such as selection, filtering, or updating items in the grid.</remarks>
1804+
</member>
17971805
<member name="M:Microsoft.FluentUI.AspNetCore.Components.SelectColumn`1.ClearSelection">
17981806
<summary>
17991807
Allows to clear the selection.

src/Core/Components/List/FluentCombobox.razor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public override async Task SetParametersAsync(ParameterView parameters)
141141
protected override async Task ChangeHandlerAsync(ChangeEventArgs e)
142142
{
143143

144-
if (e.Value is not null && Items is not null)
144+
if (e.Value is not null && Items is not null )
145145
{
146146
var value = e.Value.ToString();
147147
var item = Items.FirstOrDefault(i => GetOptionText(i) == value);
@@ -171,7 +171,7 @@ protected override async Task ChangeHandlerAsync(ChangeEventArgs e)
171171
}
172172
else
173173
{
174-
return null;
174+
return Value;
175175
}
176176
}
177177

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

22
<style>#myComponent::part(listbox) { z-index: 9995 }</style>
3-
<fluent-combobox id="xxx" position="below" blazor:oncomboboxchange="1" blazor:oncontrolinput="2" blazor:elementreference="">
3+
<fluent-combobox id="xxx" current-value="" position="below" blazor:oncomboboxchange="1" blazor:oncontrolinput="2" blazor:elementreference="">
44
<fluent-option id="xxx" value="Contoso" blazor:onclick="3" aria-selected="false" blazor:elementreference="">Contoso</fluent-option>
5-
</fluent-combobox>
5+
</fluent-combobox>

0 commit comments

Comments
 (0)