angular / angular/components

bug(autocomplete): reset input value doesn't update the selected option

Open
#20,878 1 comment 4 reactions 0 assignees View on GitHub
area: material/autocomplete P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Reproduction

When an autocomplete control is reset, the selected option still hold the `.mat-selected` class.

https://stackblitz.com/edit/angular-ufhza2
Steps to reproduce:

1) Open the autocomplete
2) Select an entry
3) Click reset
4) Open the autocomplete again

![Selection_052](https://user-images.githubusercontent.com/1753742/97108722-7c09f200-16cf-11eb-8d28-88285a935b88.png)

#### Expected Behavior

`mat-selected` class should be removed when autocomplete is empty

#### Environment

- Angular: `10.2.0`
- CDK/Material: `10.2.5`

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior in the linked StackBlitz: select an autocomplete entry, reset the control, and reopen it. Trace the autocomplete selection and reset handling to find why the selected option retains the `mat-selected` class; done means the class is removed when the input is empty, with coverage for the reported steps.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.