angular / angular/components

bug(Autocomplete): Selected option is not deselected when first input is removed while panel is closed (without clicking on input field for focus)

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

Description

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Selected option does not get deselected when the input is cleared (without clicking on input field for focus) while the panel is closed.

https://github.com/user-attachments/assets/3930b00b-7131-4b98-b29b-597b8883eb94

### Reproduction

StackBlitz link:
Steps to reproduce:
1. Click on autocomplete input field.
2. Select an option from the list.
3. Hit backspace from keyboard. (NOTE - don't click on the input to focus the field so that the panel remains closed while hitting backspace)
4. On first backspace - the selection (checkmark) remains on the previously selected option and the panel gets opened.
5. On second backspace - the selection gets cleared because panel was already open.

### Expected Behavior

The selection should get cleared since the input value has changed.

### Actual Behavior

The selection does not get cleared.

### Environment

- Angular:
- CDK/Material:
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Angular autocomplete sequence described: select an option, keep the panel closed, and press Backspace without refocusing the input. Trace how the first input change handles the selected option and panel state. Done means the selection is cleared on the first Backspace while the panel is closed; no file or test is named in the issue.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.