angular / angular/components

bug(material/chips): MatChipSelectionChange not emitting on certain deselections

Abierto
#27,909 1 comentario 0 reacciones 0 asignados Ver en GitHub
area: material/chips P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Abre la reproducción vinculada de StackBlitz e inspecciona el comportamiento de selección de MatChipOption y MatChipListbox descrito en el issue. Verifica la ruta de deselección de single-select al seleccionar el segundo chip; se considera terminado cuando el primer chip emite su evento MatChipSelectionChange al quedar deseleccionado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.