microsoft / microsoft/fluentui-blazor
fix: wrong validation state in FluentAutoComplete
Open
Nobody has claimed this yet.
bug
v5
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 483
- Avg merge
- 14h 41m
- Merged PRs (30d)
- 68
Description
🐛 Bug Report
When you set the Required parameter to true for the FluentAutocomplete component then the UI behaves wrong
- There is no validation message being shown
- The input gets the invalid state although there has been a value selected
💻 Repro or Code Sample
@page "/Debug/Test"
@using static FluentUI.Demo.SampleData.Olympics2024
@layout FluentUI.Demo.Client.Layout.EmptyLayout
<h3>Test</h3>
<div>Selected: <b>@string.Join("; ", SelectedCountries.Select(c => c.Name))</b></div>
<FluentAutocomplete TOption="Country"
TValue="string"
Width="100%"
Label="Select countries"
Placeholder="Type to search..."
OnOptionsSearch="@OnSearchAsync"
Required="true"
OptionText="@(item => item.Name)"
OptionDisabled="@(e => e.Code == "au")"
@bind-SelectedItems="@SelectedCountries" />
@code
{
IEnumerable<Country> SelectedCountries { get; set; } = [];
Task OnSearchAsync(OptionsSearchEventArgs<Country> e)
{
e.Items = Countries.Where(i => i.Name.StartsWith(e.Text, StringComparison.OrdinalIgnoreCase))
.OrderBy(i => i.Name);
return Task.CompletedTask;
}
}
- Click on the control
- Click outside of the control
- No validation message is being shown
- The input gets the red invalid border
- Click on the control
- Select an item
- Click outside the control
- The input gets the red invalid border
🤔 Expected Behavior
I expect a validation message to show up and that the invalid red border is only visible when the control is in an invalid state.
😯 Current Behavior
🌍 Your Environment
- OS & Device: Windows 11 64 Bit
- Browser latest Firefox, Edge and Chrome
- latest dev-v5 branch
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Razor repro and reproduce the Required=true behavior in FluentAutocomplete on the dev-v5 branch. Inspect the component's validation and selected-item state handling; done means an empty control shows a validation message, while a selected item is not shown with an invalid border.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100