Skip to content

bug(chips-input) NO error state ! #14195

@eusen

Description

@eusen

Bug, feature request, or proposal:

Bug

<form [formGroup]='group'>
  <mat-form-field class="example-chip-list">
    <mat-chip-list #chipList>
      <mat-chip *ngFor="let fruit of fruits" [selectable]="selectable"
              [removable]="removable" (removed)="remove(fruit)">
        {{fruit.name}}
        <mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
      </mat-chip>
      <!-- add formContorlName 'newFruit'  -->
      <input placeholder="New fruit..."
            formContorlName='newFruit'
            [matChipInputFor]="chipList"
            [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
            [matChipInputAddOnBlur]="addOnBlur"
            (matChipInputTokenEnd)="add($event)">
    </mat-chip-list>
      <!-- add mat-error  -->
    <mat-error *ngIf="group.controls.newFruit.hasError('required')">required!</mat-error>
  </mat-form-field>
</form>

What is the expected behavior?

In this case, it can display error!

What is the current behavior?

If input is empty, no error will be displayed.

What are the steps to reproduce?

https://stackblitz.com/angular/pxxkxklrgaqg?file=app%2Fchips-input-example.html
You can try it on your example..

What is the use-case or motivation for changing an existing behavior?

Displaying error prompts when errors occur

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

All latest

Is there anything else we should know?

No.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions