Skip to content

MudSelectExtended: cannot re-select previously selected option after programmatic change #556

@SpicyBoyd

Description

@SpicyBoyd

What went wrong?

After selecting “A” in a MudSelectExtended, calling its ValueChanged callback in code to set the value to “B” works—but then clicking “A” again in the dropdown does not fire ValueChanged, so you can never go back to “A.”

Reproduction steps

  1. Create a page with:
<MudSelectExtended T="string"
                   Label="RenderFragment Based"
                   Value="@Test"
                   ValueChanged="TestValueChanged">
  <MudSelectItemExtended Value="Foo" Text="Foo" />
  <MudSelectItemExtended Value="Bar" Text="Bar" />
  <MudSelectItemExtended Value="Fizz" Text="Fizz" />
  <MudSelectItemExtended Value="Buzz" Text="Buzz" />
</MudSelectExtended>

<MudButton OnClick="()=>TestValueChanged("Fizz")">Test</MudButton>

@code {
  private string Test;

  private void TestValueChanged(string value)=>Test = value;
}
  1. Run, open dropdown, select Foo.
  2. Click the Test button to programmatically change the value to Fizz.
  3. Open dropdown again and select Foo — TestValueChanged("Foo") does not fire.

Expected behavior

After programmatically changing Value to “Fizz,” selecting “Foo” again should fire ValueChanged("Foo") and update the bound value.

Actual behavior

The UI shows Foo as selected in the list, but ValueChanged is never called, and the bound value remains “Fizz.”

Workarounds tried

Temporary: bind via SelectedValues="[Test]", which allows selecting the same item again but is not ideal for single-value scenarios.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions