angular / angular/components

bug(matFormField): Form field state not being updated properly when input dynamically changes

Open
#28,495 0 comments 0 reactions 0 assignees View on GitHub
area: material/form-field P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

version 14

### Description

When dynamically changing the input type of a form field, the label and error state of the for field is not properly reflected, the label will not float up and the form outline color will not be set. [See demo example](https://stackblitz.com/edit/nmqf81?file=src%2Fexample%2Fform-field-hint-example.html)

Confirmed that id used to work properly in version 14 [see demo working](https://stackblitz.com/edit/vaqmlj?file=src%2Fapp%2Fform-field-overview-example.ts,src%2Fapp%2Fform-field-overview-example.html)

### Reproduction

Steps to reproduce:
1. open [demo](https://stackblitz.com/edit/nmqf81?file=src%2Fexample%2Fform-field-hint-example.html)
2. toggle slider
3. click submit
4. see that label has not floated and form outline is not red
5. open v14 demo and see it working properly [stackblitz](https://stackblitz.com/edit/vaqmlj?file=src%2Fapp%2Fform-field-overview-example.ts,src%2Fapp%2Fform-field-overview-example.html)

### Expected Behavior

Form field should allow inputs to dynamically change

### Actual Behavior

Error state and label are not propely reflected

### Environment

- Angular: 17
- CDK/Material: 17

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and compare its Angular 17 behavior with the provided version 14 demo while tracing the Angular Material form-field state changes. Reproduce the dynamic input-type toggle and submit flow; done means the label floats and the form outline reflects the error state after the input changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.