Skip to content

Commit e749431

Browse files
authored
feat(material/core): change ErrorStateMatcher to accept AbstractForm instead of FormControl (#24012)
1 parent 2e40f7c commit e749431

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/material/core/error/error-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
*/
88

99
import {Injectable} from '@angular/core';
10-
import {FormGroupDirective, NgForm, FormControl} from '@angular/forms';
10+
import {FormGroupDirective, NgForm, AbstractControl} from '@angular/forms';
1111

1212
/** Error state matcher that matches when a control is invalid and dirty. */
1313
@Injectable()
1414
export class ShowOnDirtyErrorStateMatcher implements ErrorStateMatcher {
15-
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
15+
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {
1616
return !!(control && control.invalid && (control.dirty || (form && form.submitted)));
1717
}
1818
}
1919

2020
/** Provider that defines how form controls behave with regards to displaying error messages. */
2121
@Injectable({providedIn: 'root'})
2222
export class ErrorStateMatcher {
23-
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
23+
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean {
2424
return !!(control && control.invalid && (control.touched || (form && form.submitted)));
2525
}
2626
}

tools/public_api_guard/material/core.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
```ts
66

77
import { _AbstractConstructor as _AbstractConstructor_2 } from '@angular/material/core';
8+
import { AbstractControl } from '@angular/forms';
89
import { AfterViewChecked } from '@angular/core';
910
import { BooleanInput } from '@angular/cdk/coercion';
1011
import { ChangeDetectorRef } from '@angular/core';
@@ -14,7 +15,6 @@ import { EventEmitter } from '@angular/core';
1415
import { FocusableOption } from '@angular/cdk/a11y';
1516
import { FocusOptions as FocusOptions_2 } from '@angular/cdk/a11y';
1617
import { FocusOrigin } from '@angular/cdk/a11y';
17-
import { FormControl } from '@angular/forms';
1818
import { FormGroupDirective } from '@angular/forms';
1919
import { HighContrastModeDetector } from '@angular/cdk/a11y';
2020
import * as i0 from '@angular/core';
@@ -133,7 +133,7 @@ export const defaultRippleAnimationConfig: {
133133
// @public
134134
export class ErrorStateMatcher {
135135
// (undocumented)
136-
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean;
136+
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean;
137137
// (undocumented)
138138
static ɵfac: i0.ɵɵFactoryDeclaration<ErrorStateMatcher, never>;
139139
// (undocumented)
@@ -568,7 +568,7 @@ export function setLines(lines: QueryList<unknown>, element: ElementRef<HTMLElem
568568
// @public
569569
export class ShowOnDirtyErrorStateMatcher implements ErrorStateMatcher {
570570
// (undocumented)
571-
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean;
571+
isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean;
572572
// (undocumented)
573573
static ɵfac: i0.ɵɵFactoryDeclaration<ShowOnDirtyErrorStateMatcher, never>;
574574
// (undocumented)

0 commit comments

Comments
 (0)