-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mat-select doesn't show mat-error on submit #7634
Comments
ok, I solved like this: <mat-form-field>
<mat-select placeholder="Fruits" #fruitSelect required [formControl]="fruit">
<mat-option *ngFor="let f of fruits" [value]="f">
{{f}}
</mat-option>
</mat-select>
<mat-error *ngIf="fruitSelect.errorState && fruit.hasError('required')">
<strong>required</strong>
</mat-error>
</mat-form-field> I added a variable I first tested with only I have no idea why only |
Fixes `mat-select` error messages not being shown when the parent form is submitted. Fixes angular#7634.
Fixes `mat-select` error messages not being shown when the parent form is submitted. Fixes angular#7634.
It's definitely a bug. Until #7640 gets in you should be able to work around it by calling |
Fixes `mat-select` error messages not being shown when the parent form is submitted. Fixes #7634.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Should show mat-error on submit (if invalid)
What is the current behavior?
mat-select becomes red as expected, but mat-error doesn't appear until clicked/touched.
doing
control.markAsTouched()
,control.markAsDirty()
on submit, also doesn't work.What are the steps to reproduce?
https://stackblitz.com/edit/angular-material2-issue-yxmtsq
Validators.required
)select
, click on submit.select becomes red (invalid), but
mat-error
doesn't appear until you click/touch on the select.What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: ^4.4.4,
"@angular/cdk": "^2.0.0-beta.12",
"@angular/material": "^2.0.0-beta.12",
"typescript": "^2.5.2",
OS: macOS Sierra
browser: Chrome
Is there anything else we should know?
Thanks :D
The text was updated successfully, but these errors were encountered: