bug(material/chips): MatChipSelectionChange not emitting on certain deselections
- 主要语言
- 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
`selectionChange` output for `MatChipOption` is [stated to be](https://material.angular.io/components/chips/api#MatChipOption):
> Emitted when the chip is selected or **deselected**.
But this is not true for deselection. It appears the event is only emitted for deselection when **the chip in question** is manually selected/toggled by the user. When the `MatChipListbox` is **in single-select mode and a chip is currently selected**, selecting a different chip means the prior chip is deselected --> deselecting should mean emitting the `selectionChange` event, but it is not happening in this scenario.
See the below StackBlitz link.
### Reproduction
StackBlitz link: https://stackblitz.com/edit/firqg1
Steps to reproduce:
(First chip is initially selected)
1. Click on the Second chip.
2. First chip becomes deselected, but no `selectionChange` output event was emitted (in this case, the `MatChipSelectionChange` object should be logged to the console).
### Expected Behavior
`selectionChange` output for the First chip should have emitted.
### Actual Behavior
`selectionChange` output for the First chip does not emit.
### Environment
- Angular: 16
- CDK/Material: 16.2.7 (latest)
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
贡献指南
调研方向
打开链接的 StackBlitz 复现,并检查 issue 中描述的 MatChipOption 和 MatChipListbox 选择行为。验证选择第二个 chip 时的 single-select 取消选择路径;当第一个 chip 被取消选择时发出其 MatChipSelectionChange 事件,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100