Skip to content

Ensure directives appear in errorTailor context  #27

@dev054

Description

@dev054

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

No error for this template:

<form [formGroup]="formGroup">
  <mat-form-field>
    <mat-label>Name</mat-label>
    <input matInput formControlName="name" [controlErrorAnchor]="nameError" />
    <mat-error><ng-template controlErrorAnchor #nameError="controlErrorAnchor"></ng-template></mat-error>
  </mat-form-field>
</form>

Expected behavior

Error for the template above, as there's no errorTailor hosted in <form>.

What is the motivation / use case for changing the behavior?

Currently if we try to use the directive controlErrorAnchor (also in others, but I just tested with controlErrorAnchor) without form, for example, we get no error and it lead us for a difficult debug caused due to a silly mistake. I want to propose a check (probably only in devMode) in this "children" directives in order to avoid losing time with this.

Environment


Angular version: 11.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions