Skip to content

[Autocomplete]: autoActiveFirstOption not working when tabbing in with disabled floatLabel #13734

Closed
@thomaspink

Description

@thomaspink

Bug, feature request, or proposal:

When tabbing into (not clicking!) an autocomplete with autoActiveFirstOption enabled and floatLabel disabled on the form field, the first option does not become active.
It will become active if you press another key after tabbing in, inspecting the element or any other action that cause an event for the zone.

When adding this._changeDetectorRef.detectChanges(); in autocomplete-trigger.ts at line 500, it works (src/lib/autocomplete/autocomplete-trigger.ts:500).

My guess is that at this point the zone is stable and all the changes done (setting the active option, ...) are not picked up for the CD.
When enabling floatLabel, it works as expected. So it seems that the floatLabel triggers another CD after that, and the changes will get recognized.

What is the expected behavior?

First option should be active.

What is the current behavior?

First option is not active.

What are the steps to reproduce?

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

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Current versions.
Forked the existing material autocomplete autoActiveFirstOption stackblitz example.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions