fluentui-blazor icon indicating copy to clipboard operation
fluentui-blazor copied to clipboard

FluentCombobox OnValueChanged is called twice when the item selected has more than one space in the middle of the items string or an extra space at the beginning or end of the string.

Open scheatham-citadel opened this issue 2 years ago • 1 comments

🐛 Bug Report

FluentCombobox OnValueChanged is called twice when the item selected has more than one space in the middle of the items string or an extra space at the beginning or end of the string.

When OnValueChanged is called twice, the function is reentered a second time prior to the first call being completed.

This cannot be fixed in user code without elaborate workarounds when data comes from a database or other source.

💻 Repro or Code Sample

@page "/test"

<FluentCombobox Items="@_items" ValueChanged="@OnValueChanged" />

@code
{
    private List<string> _items = ["good", "good good", "bad  bad", "bad ", " bad"];

    private async Task OnValueChanged(string? value)
    {
        Debug.WriteLine($"Start: '{value}')");

        await Task.Delay(100);

        Debug.WriteLine($"End: '{value}')");
    }
}

🤔 Expected Behavior

When you select 'good' you get this expected output in the Output window:
Start: 'good')
End: 'good')

When you select 'good good' you get this expected output in the Output window:
Start: 'good good')
End: 'good good')

😯 Current Behavior

When you select 'bad  bad' you get this unexpected output in the Output window:
Start: 'bad bad')
Start: 'bad  bad')
End: 'bad  bad')
End: 'bad bad')

When you select 'bad ' you get this unexpected output in the Output window:
Start: 'bad')
Start: 'bad ')
End: 'bad ')
End: 'bad')

When you select ' bad' you get this unexpected output in the Output window:
Start: 'bad')
Start: ' bad')
End: 'bad')
End: ' bad')

🌍 Your Environment

.NET 8 Fluent UI Blazor library Version 4.10.2 Blazor Server Microsoft Edge for Business Version 130.0.2849.52 (Official build) (64-bit)

scheatham-citadel avatar Oct 23 '24 18:10 scheatham-citadel

Fixed with PR mentioned above. Will be in nex release

vnbaaij avatar Oct 23 '24 21:10 vnbaaij