Skip to content

Commit 35f9e1a

Browse files
authored
Fix combobox GetOptionValue (microsoft#3739)
* Fix combobox GetOptionValue * Update the current-value * Fix Unit Test
1 parent 1335562 commit 35f9e1a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/Core/Components/List/FluentCombobox.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
style="@StyleValue"
1515
autocomplete="@Autocomplete.ToAttributeValue()"
1616
open=@Open
17-
current-value=@Value
17+
current-value=@GetComboboxContent()
1818
placeholder=@Placeholder
1919
position=@Position.ToAttributeValue()
2020
disabled=@Disabled

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ protected override async Task ChangeHandlerAsync(ChangeEventArgs e)
163163
}
164164
}
165165

166-
protected override string? GetOptionValue(TOption? item)
166+
private string? GetComboboxContent()
167167
{
168-
if (item != null)
168+
if (SelectedOption != null)
169169
{
170-
return OptionText.Invoke(item) ?? OptionValue.Invoke(item) ?? item.ToString();
170+
return OptionText.Invoke(SelectedOption) ?? OptionValue.Invoke(SelectedOption) ?? SelectedOption.ToString();
171171
}
172172
else
173173
{
Lines changed: 1 addition & 1 deletion
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" current-value="" position="below" blazor:oncomboboxchange="1" blazor:oncontrolinput="2" blazor:elementreference="">
3+
<fluent-combobox id="xxx" 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>
55
</fluent-combobox>

0 commit comments

Comments
 (0)