fix: option list stays open after a mouse pick in single-select FluentAutocomplete

Aperta
#5,715 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@dvoituron ci sta già lavorando.

Dal 3/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

🐛 Bug Report

In v5, a FluentAutocomplete with Multiple="false" keeps its option list open after the user clicks an option. The pick is saved and shown, but the list stays open over the page until the user clicks somewhere else or presses Escape.

A pick made with the keyboard (ArrowDown + Enter) closes the list, so mouse and keyboard behave differently. In v4, the list closed after each pick (see #2819, which asked for a keepOpen option).

💻 Repro or Code Sample

<FluentAutocomplete TOption="string" TValue="string"
                    Label="Specialty"
                    Multiple="false"
                    ImmediateDelay="0"
                    OnOptionsSearch="Search"
                    @bind-SelectedItem="_picked" />

@code {
    private string? _picked;
    private static readonly string[] Items = ["Cardiology", "Dermatology", "Neurology", "Urology"];

    private void Search(OptionsSearchEventArgs<string> args) =>
        args.Items = Items.Where(item => item.Contains(args.Text ?? "", StringComparison.OrdinalIgnoreCase));
}
  1. Click the input and press ArrowDown, or type "o", to open the list.
  2. Click "Cardiology" with the mouse.

🤔 Expected Behavior

The list closes after the pick, as it does after Enter, and aria-expanded becomes false.

😯 Current Behavior

  • "Cardiology" shows as the picked value.
  • The list stays open: the fluent-popover-b keeps opened="true", and the other options stay visible and clickable.

💁 Possible Solution

InternalSelectedItemsChangedHandlerAsync (src/Core/Components/List/FluentAutocomplete.razor.cs) updates the pick and calls SetInputFocusAsync(), but it never sets _isOpen = false. The Enter path closes the list in two places: OnTextInputKeyDownAsync sets _isOpen = false, and the script calls Popover.closePopover().

A possible fix is to close the list in the single-select branch of that handler:

// Multiple = False
else
{
    ...
    _isOpen = false;
}

A multi-select list must stay open, so that the user can pick more items.

The code on dev at 9eb965ae is the same as in 5.1.0, so 5.2 still has this bug.

As a workaround, we call closePopover() on fluent-popover-b[anchor-id="<input id>"] after the pick renders. The popovertoggle event then sets Opened back to false, through OnToggleAsync and @bind-Opened.

🔦 Context

Single-select pickers (a long dropdown list, a person search, a group search) leave their list over the rest of the form after each mouse pick. Users read this as a broken dropdown.

🌍 Your Environment

  • OS & Device: Windows 11 on PC
  • Browser: Chromium (Playwright) and a Chromium-based desktop browser
  • .NET 10 and Fluent UI Blazor 5.1.0 (Blazor WebAssembly); also checked against dev at 9eb965ae
Lingua principale
C#
Stelle
4.9k
Fork
500
Merge medio
15h 28m
PR unite (30g)
58

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/fluentui-blazor

Tutte le issue di microsoft/fluentui-blazor

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.