angular / angular/components

bug(ErrorStateMatcher): Not able to configure globally ErrorStateMatcher

Offen
#20,097 4 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/input P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Reproduction

StackBlitz link for reproduction: https://stackblitz.com/edit/components-issue-enshvf

Steps to reproduce:
1. Pay your attention that CoreModule has declaration for `ErrorStateMatcher` provider with class `ShowOnDirtyErrorStateMatcher`. CoreModule imported into AppModule in the same way as FeatureModule.
2. Try to focus/blur example "Favorite Food" input and note that `ShowOnDirtyErrorStateMatcher` was not applied.

In big enterprise applications we should have clean modular structure without any SharedModule or MaterialModule to be imported into each feature module.

MatInputModule has hardcoded `ErrorStateMatcher` provider and when we import that module into our feature modules – our global `ErrorStateMatcher` provider is overwritten.

I suppose this issue related with PR #18962, but I believe this issue describes another problem with `ErrorStateMatcher`

#### Expected Behavior

ErrorStateMatcher can be defined globally

#### Actual Behavior

ErrorStateMatcher overwrites with each MatInputModule import

#### Environment

- Angular: 9+
- CDK/Material: 9+

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der verknüpften StackBlitz-Reproduktion und verfolge, wie ErrorStateMatcher von CoreModule, FeatureModule und MatInputModule bereitgestellt wird. Überprüfe das Provider-Verhalten, wenn MatInputModule in mehreren Feature-Modulen importiert wird; abgeschlossen ist die Aufgabe, wenn ein global konfigurierter ErrorStateMatcher weiterhin wirksam bleibt und das Favorite Food-Eingabefeld der Reproduktion ihn verwendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.