angular / angular/components

bug(CdkListbox): cdkOption requires additional event to rerender after list of options changed

未关闭
#28,828 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/listbox 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

When any **option was selected** in the list and than user filtered them somehow and back to the initial list, **that selected option** will be rendered incorrectly.

https://github.com/angular/components/assets/13451032/4392054a-68e3-439e-a250-0084c943d37d

P.S. A bit similar problem was there: https://github.com/angular/components/issues/28557

### Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-xvgkha?file=src%2Findex.html,src%2Fmain.ts
Steps to reproduce:
1. Click **"Ron"** option (it becomes true)
2. Type in `input` letter **"J"**
3. Remove letter **"J"**
4. See that option **"Ron"** is false.
5. Type in input letter **"R"** or click outside `input`
6. See that option **"Ron"** is true.

### Expected Behavior

Option should be rendered immediately based on its internal state (`isSelected()/isActive()`).

### Actual Behavior

Option requires one more event to be rendered based on its internal state (`isSelected()/isActive()`).

### Environment

- Angular: 17
- CDK/Material: 17.3.3
- Browser(s): Chrome and Safari
- Operating System (e.g. Windows, macOS, Ubuntu):

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,尤其查看 src/index.html 和 src/main.ts,并跟踪 CdkListbox 和 cdkOption 的筛选步骤。比较列表恢复到初始内容后所选选项的渲染状态。完成的标准是:选项能够根据其内部 isSelected()/isActive() 状态立即渲染,而不需要再次触发输入或焦点事件。

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

评估

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

把新 issue 发到你的邮箱

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