Skip to content

bug(MatAutocomplete): when using single mat-autocomplete with multiple inputs, panel does not open in some circumstances and displays incorrect option as selected #28362

@bart113

Description

@bart113

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

14.2.7

Description

MatAutocomplete enters a broken state (invisible, but clickable), when the following conditions are met:

  • a single <mat-autocomplete> instance is used by multiple <input>s
  • user moves focus between these inputs using a mouse

Reproduction

StackBlitz link: https://stackblitz.com/edit/ajkqp1?file=src%2Fexample%2Fautocomplete-simple-example.html

Steps to reproduce:

  1. Open the StackBlitz demo.
  2. Click the "Number 2" input.
  3. Observe that the autocomplete panel is now open.
  4. Click the "Number 1" input.

Expected Behavior

The autocomplete panel for the "Number 1" input is now open.

Actual Behavior

The autocomplete panel was visible for a brief moment, and then disappeared.

In particular, the panel still exists and is clickable, but has opacity: 0. This style appears to have been set by the animation of the panel that has just been closed.

Note that:

  • The bug cannot be observed, if user does not click, but uses Tab to navigate between the <input> fields.
  • The panel works correctly in Angular Material 17, if every input has its own <mat-autocomplete> defined. Demo.
  • Using a single <mat-autocomplete> for multiple <input>s used to work in Angular Material 14.2.7. Demo.

Environment

  • Angular: 17.0.0
  • CDK/Material: 17.0.4
  • Browser(s): Chrome 120.0.6099.129
  • Operating System: Linux

Metadata

Metadata

Assignees

Labels

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