angular / angular/components

bug(Autocomplete): matAutocomplete with control initial value does not highlight value in options with check icon

未关闭
#29,422 7 条评论 13 个 reaction 已指派 0 人 在 GitHub 查看
area: material/autocomplete P3
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### 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

A MatAutocomplete field initialized with a control value does not highlight item in options

### Reproduction

StackBlitz link: https://stackblitz.com/edit/saqfud?file=src%2Fexample%2Fautocomplete-filter-example.ts,src%2Fexample%2Fautocomplete-filter-example.html,src%2Fexample%2Fautocomplete-filter-example.css
Steps to reproduce:
1. Set initial value of control (second one value for example)
```
options: string[] = ['One', 'Two', 'Three'];
myControl = new FormControl(this.options[1]);
```
3. click on input on UI

### Expected Behavior

Second one option is highlighted
![image](https://github.com/angular/components/assets/60134428/1d2c8684-8dc5-42dc-8433-7051b02926f6)

### Actual Behavior

second option is not highlighted
![image](https://github.com/angular/components/assets/60134428/635ef0d6-bf94-4523-b8b3-38014f7c2356)

### Environment

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

贡献指南

打开贡献指南

调研方向

首先运行链接的 StackBlitz 复现,并检查 src/example/autocomplete-filter-example.ts 和 src/example/autocomplete-filter-example.html。确认存在一个初始选中的值,但打开输入框时其选项没有高亮显示。对于提供的初始 FormControl 值,如果第二个选项始终高亮显示,并且有一个覆盖该行为的回归测试,则视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。