@bind-Value on FluentCombobox binds to the displayed text, not the value
See original GitHub issue🐛 Bug Report
FluentCombobox should bind to the value of the selected FluentOption, instead of the displayed part.
💻 Repro or Code Sample
I have a Blazor wasm project. When I make a FluentCombobox, and bind a string using @bind-Value, the contents of the string is set to the diplayed part of the combobox.
@page "/ViewCustomers"
<h1>View Customers</h1>
Selected Value: @selectedCustValue
<FluentCombobox Autocomplete="Autocomplete.List" @bind-Value="selectedCustValue">
@foreach (var cust in customers)
{
<FluentOption Value="@cust.Id.ToString()">@cust.Name</FluentOption>
}
</FluentCombobox>
}
@code {
string selectedCustValue = "";
List<Customer>? customers = new(
new []{new Customer{Id = 0, Name = "abc"}});
}
🤔 Expected Behavior
selectedCustValue should contain the value set in the selected FluentOption (“0” in the example)
😯 Current Behavior
The displayed part of the selected FluentOption is set in SelectedCustValue (“abc” in the example)
🔦 Context
I need the id, since I cannot guarantee that the Name value is unique.
🌍 Your Environment
- OS & Device: Windows 11
- Browser Google Chrome
- .NET and FAST Version .NET 6.0 Microsoft.Fast.Components.FluentUI v. 1.1.0 (LAtest NuGet package)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (5 by maintainers)
Top Results From Across the Web
How to two-way-bind a value in FluentListBox - blazor
Trying this out in a new Blazor project shows that _value does not change when selecting a new value. When I manually set...
Read more >fix: FluentSelect does not update when SelectedOption ...
When I hit Previous, Previous it does not update. ... fix: Value set from outside of component is not displayed in FluentCombobox. #308....
Read more >Blazor bind-value vs bind-Value : r/dotnet
i've always use @bind-Value. however, i got a error message "The attribute names could not be inferred from bind attribute 'bind-Value'.
Read more >PDOStatement::bindValue - Manual
Description ¶ Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the...
Read more >Data Binding - Blazor ComboBox - Documentation
A Value that is non- default will not show the Placeholder . Handling such "unexpected" values is up to the application - for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m redoing the
FluentCombobox,FluentListboxandFluentSelectfor V2. A (strongly typed)SelectedItemwill be supported there. I also have theValueworking as of now, but that does not reflect a typed in value and I don’t think I can get to that typed in value. I guess it depends on what behavior we expect a combobox to have: 1) an alternative to a select where you can search through the list by typing in the input or 2) a combination (hence the name) of an input and a select list where a use can enter free-form text.@atmgrifter00 With regards to the specification for combobox, this is expected behavior as described in my previous comment. Having separate values for combobox options can conflict with the ability to enter and submit custom values.
A combobox is like a text input with supplementary predetermined options, whereas a select is like a collapsible listbox. In fact, the element internals for combobox use an
input, since unlikeselect, there is no native control which reflects the accessibility requirements of a user-editable combobox.The reason a combobox doesn’t use the
valueof its options comes down to avoiding the potential for user-defined values that are similar, but different, from any pre-configured values (ex. “fooBAR” vs “FOObar”). While the autocomplete functionality can do a basic job of filtering the list and auto-filling potential matches, there’s no way to confirm if a user’s input is an incomplete fuzzy search or a specific custom value.With that said, there are a few useful ways to get the selected items from the DOM:
selectedIndexandselectedOptionsproperties which can be used to determine which item is currently selected.selectedboolean property which can be used instead of checking theclass.My own personal experience with Blazor is limited, so I don’t know if getting the element properties would require hooking it up in this project.
One more alternative would be to use the
FluentSelectcomponent, which doesn’t allow for direct user-specified values but does use the values of its selected options for its own. It also supports type-ahead to select the first matching option as you start typing while it’s focused.