Skip to content

MatAutocompleteTrigger throws error when typing into input with matAutocompleteDisabled=true and matAutomplete=null #11876

@gtranter

Description

@gtranter

Bug, feature request, or proposal:

Bug

What is the expected behavior?

If the autocomplete is disabled, the keyboard should not try to operate the autocomplete, and no error should be thrown as a result.

What is the current behavior?

When the matAutocomplete is null and matAutocompleteDisabled is true, typing into the input triggers the keydown handler of MatAutocompleteTrigger which in turn tries to use the autocomplete. Since the autocomplete is null, an error occurs.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-nlivwf

What is the use-case or motivation for changing an existing behavior?

Fix a bug and restore proper operation.

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

Angular 6.0.5 Angular Material 6.3.0

Is there anything else we should know?

The new matAutocompleteDisabled feature comes from #11096 which was implemented by #11142. Simply using [matAutocomplete]="null" [matAutocompleteDisabled]="true" demonstrates the problem - however it doesn't make sense to do that. The purpose of request was to allow for creating a custom component using mat-form-field with an optional autocomplete. My Stackblitz example above shows this.

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions