Skip to content

bug(mat-autocomplete): autoActiveFirstOption selects disabled <mat-option> #21498

@brendanowens

Description

@brendanowens

Reproduction

StackBlitz: https://stackblitz.com/edit/angular-qrv3v7?file=src/app/autocomplete-auto-active-first-option-example.html

Steps to reproduce:

  1. Search for "AB" in the form field
  2. Notice that the first option (AB) is automatically active
  3. Notice that the first option is greyed out because it is a disabled

Expected Behavior

The first active should be automatically selected if autoActiveFirstOption is set for the . This is the behavior when using the arrow up/down keys that any disabled are not highlighted as you use the arrow up/down keys. In this example, the option "ABC" should be automatically active since it is the first active that matches the autocomplete search text.

Actual Behavior

In the example, the first becomes active, regardless of if it has its disabled input property set to true.

Environment

  • Angular: 11.0.0
  • CDK/Material: 11.0.0
  • Browser(s): Chrome 87.0.4280.88
  • Operating System: macOS 10.15.7

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