question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not disable custom MatFormFieldControl with FormControl with mat-autocomplete

See original GitHub issue

Bug, feature request, or proposal:

  • Potential bug

What is the expected behavior?

A component implementing MatFormFieldControl with a mat-autocomplete can be disabled correctly via a FormControl.

What is the current behavior?

It is not possible to have a custom MatFormFieldControl implementation with a mat-autocomplete and have the input disabled via a FormControl. Notice in the StackBlitz application, it is possible to open the autocomplete overlay of the field and select an option even when the field is set to disabled.

If the FormControl is removed from the input element in custom-input and a binding to [disabled] is used, the behaviour works as expected. The reason I am using a FormControl here is to automatically apply validators to the input, so they are not needed to be added manually by the consumer of the form field everywhere it is used.

It does however work correctly when adding matInput to the input element inside custom-input. Is this the intended behaviour? The CDK Docs here do not include it.

What are the steps to reproduce?

https://stackblitz.com/edit/custom-mat-form-field-with-auto-complete

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

To be able to disable the input when an autocomplete is attached, or be clearer in the docs when matInput is needed still.

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

Latest from NPM (see StackBlitz)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
crisbetocommented, Nov 30, 2017

Sorry, now I see what you mean. I’ll take a look at it.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular mat-autocomplete disable input FormControl not ...
I am working on a custom components library, and we have a custom autocomplete component with chips. I want to be able to...
Read more >
Creating a custom form field control - Angular Material
It is possible to create custom form field controls that can be used inside <mat-form-field> . This can be useful if you need...
Read more >
Angular – How to stop mat-autocomplete to take custom user ...
I am using mat-auto complete component from material.angular.io. The default behavior is user can input any value as well as it gives options...
Read more >
mat-form-field must contain a matformfieldcontrol mat-checkbox
Actually the error doesn't mean a module import problem, but that you're using the mat-form-field without a valid control. The problem is here...
Read more >
Autocomplete overview - StackBlitz
aria-label="State" [matAutocomplete]. ="auto" [formControl]="stateCtrl" ... Disable Input? </mat-slide-toggle> ... Use of this source code is governed by an.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found