Skip to content
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

feat(material/form-field): Ability to support custom error message components inside a form field #25399

Merged
merged 3 commits into from Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/material/form-field/directives/error.ts
Expand Up @@ -19,7 +19,7 @@ export const MAT_ERROR = new InjectionToken<MatError>('MatError');

/** Single error message to be shown underneath the form-field. */
@Directive({
selector: 'mat-error',
selector: 'mat-error, [matError]',
host: {
'class': 'mat-mdc-form-field-error mat-mdc-form-field-bottom-align',
'aria-atomic': 'true',
Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/form-field.html
Expand Up @@ -83,7 +83,7 @@
[ngSwitch]="_getDisplayedMessages()">
<div class="mat-mdc-form-field-error-wrapper" *ngSwitchCase="'error'"
[@transitionMessages]="_subscriptAnimationState">
<ng-content select="mat-error"></ng-content>
<ng-content select="mat-error, [matError]"></ng-content>
</div>

<div class="mat-mdc-form-field-hint-wrapper" *ngSwitchCase="'hint'"
Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/testing/shared.spec.ts
Expand Up @@ -271,7 +271,7 @@ export function runHarnessTests(
<input matInput [formControl]="requiredControl">

<mat-error>Error 1</mat-error>
<mat-error>Error 2</mat-error>
<div matError>Error 2</div>
<mat-hint align="start">Hint 1</mat-hint>
<mat-hint align="end">Hint 2</mat-hint>
</mat-form-field>
Expand Down