Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SelectedOptionChanged called twice in FluentCombobox #2077

Closed
nwoolls opened this issue May 20, 2024 · 2 comments
Closed

fix: SelectedOptionChanged called twice in FluentCombobox #2077

nwoolls opened this issue May 20, 2024 · 2 comments
Labels
status:in-progress Work is in progress

Comments

@nwoolls
Copy link

nwoolls commented May 20, 2024

🐛 Bug Report

I am trying to handle scenarios where a user clears the value in a FluentCombobox, or types a value that is not in the list. I am using SelectedOptionChanged to do so. However, SelectedOptionChanged is called twice, once with a parameter of null and then again with the previously selected item, even though the rendered combo box does not have the previously selected item in it.

💻 Repro or Code Sample

dotnet new fluentblazor
@rendermode InteractiveServer

<FluentCombobox Items="_items"
                TOption="string"
                SelectedOptionChanged="x => HandleOriginProductChanged(x)"/>

@code {
    private List<string> _items = [ "Item 1", "Item 2", "Item 3" ];

    private void HandleOriginProductChanged(string? value)
    {
        Console.WriteLine($"Selected product: {value}");
    }
}
  1. Run the above sample
  2. Select "Item 1" from the combo
  3. Select "Item 2" from the combo
  4. Clear out the selected value (or type a value that does not exist in the list)

🤔 Expected Behavior

Console log:

Selected product: Item 1
Selected product: Item 2
Selected product: 

😯 Current Behavior

Console log:

Selected product: Item 1
Selected product: Item 2
Selected product: 
Selected product: Item 2

💁 Possible Solution

N/A - I may be willing to work on a fix time permitting.

🔦 Context

FWIW I saw a similar issue here that was fixed in 4.7.2, but I am still seeing the problem reported above:

🌍 Your Environment

  • OS & Device: MacOS
  • Browser: Google Chrome, Apple Safari
  • .NET and Fluent UI Blazor library Version: 8.0.5 and 4.7.2
@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label May 20, 2024
@vnbaaij vnbaaij added status:in-progress Work is in progress and removed triage New issue. Needs to be looked at labels May 29, 2024
@vnbaaij
Copy link
Collaborator

vnbaaij commented May 29, 2024

We are in the middle of changing the list components to inherit from InputBase (instead of ComponentBase). We will take this in as part of that work.

@vnbaaij
Copy link
Collaborator

vnbaaij commented May 31, 2024

Can confirm that this will be fixed with PR #2118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:in-progress Work is in progress
Projects
None yet
Development

No branches or pull requests

2 participants