When I have a form and I add a FormControl, fields that are required and untouched become red.
It should not become red as we haven't touched these fields yet.
It adds the class mat-form-field-invalid resulting in red text without triggering a proper validation.
https://stackblitz.com/edit/angular-y6f4xv?file=src%2Fapp%2Fprofile-editor%2Fprofile-editor.component.html
Go to the page, add an Alias (new FormControl in the FormArray) without touching anything else. The firstNameMaterial field becomes red because the mat-form-field adds a “mat-form-field-invalid” class.
Annoying form bug
Angular 6.1.2 / Material 6.4.5
Note: This is a stripped down version of the official Angular documentation on reactive forms: https://angular.io/guide/reactive-forms
That happens because the button that is adding the alias is submitting the form at the same time. You should add type="button" if you don't want it to submit.
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._
Most helpful comment
That happens because the
buttonthat is adding the alias is submitting the form at the same time. You should addtype="button"if you don't want it to submit.