Skip to content

bug(MatAutocomplete): Resetting form still shows previous selected item #27652

@drberg

Description

@drberg

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Resetting a form with autocomplete gives a visual impression that item is still selected.

I thought the fix from #26761 would solve my issue, but unfortunately it persisted after updating.

Reproduction

StackBlitz link: https://stackblitz.com/edit/zdy1sg

Steps to reproduce:

  1. Open autocomplete.
    image
  2. Click 'Two'.
    image
  3. Click 'Reset selection'. Notice that the input box is now empty.
    image
  4. Open autocomplete again and observe that 'Two' is still marked as selected even though the value is not set in the form any more.
    image

Expected Behavior

I expected the selection list not to show any selected items when the form is reset.

Actual Behavior

Previous selected item appears selected when it's not in the form.

Environment

  • Angular: 16.2.0
  • CDK/Material: 16.2.0
  • Browser(s): Edge and Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    AccessibilityThis issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/autocomplete

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions