angular / angular/components

bug(mat-chip): mat-chip does not react to [selected] binding when the mat-chip-list also contains a formControl (e.g.) official autocomplete example

Open
#21,999 5 comments 2 reactions 0 assignees View on GitHub
area: material/autocomplete area: material/chips P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Reproduction

This example is copied directly from the official "Chips Autocomplete" example ([https://material.angular.io/components/chips/examples]). I have just stripped some of the unnecessary bits for a minimal example.

The example shows 3 copies of same mat-chip-list showing how mat-chips do not react to [selected] binding when a mat-input with either [formControl] or [matAutocomplete] bindings are included in the mat-chip-list.

All the existing chips should be selected in all copies. The only difference between the 3 is what bindings are included in the

https://components-issue-y2hda6.stackblitz.io

Steps to reproduce:
1. Create a mat-chip-list with mat-chips that have a [selected] binding (or just static flag set)
2. Add a with either [matAutocomplete] or [formControl]
3. The mat-chips no longer reflect their "selected" css styles (although appear to be internally in selected state)

#### Expected Behavior

For all chips to be selected in all copies

#### Actual Behavior

Presence of [formControl] or [matAutocomplete] prevents css styles being applied to selected chips

#### Environment

- Angular: 11.1.1
- All OS/Browser

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz reproduction and compare it with the official Chips Autocomplete example. Inspect the mat-chip-list and mat-chip behavior when the input uses [formControl] or [matAutocomplete]. Done means the existing chips apply their selected CSS styles in all three reproduced cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.