angular / angular/components

bug(material/chip): textContent of any HTML element inside mat-chip-row is being appended to FormControl value on focus out (blur) event

Ouverte
#27,839 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
area: material/chips P3
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

### Is this a regression?

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

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

14

### Description

When there is any HTML element inside ``, or even just the matChipRemove button is wrapped inside some `` (like with `*ngIf`, checking if the user has the privilege to delete), then the whole chip-row's value contains this element's textContent (button with `cancel` in this case) after focusing out of the component.

So for example, value `["Apple"]` becomes `["Apple cancel"]` (because `cancel` is part of ``'s textContent).

```

{{ fruit }}


cancel

```

(when `matChipRemove` button is not wrapped inside `` or any other HTML element then its textContent is being ignored, which, I guess, is correct behavior)

### Reproduction

StackBlitz link:
https://stackblitz.com/edit/ovb2sn-s41kjs?file=src%2Fapp%2Fchips-autocomplete-example.html,src%2Fapp%2Fchips-autocomplete-example.ts

Steps to reproduce:
Click on the text input and then focus it out.
This will run Material's blur/focusOut code and update the form control value with the chips' textContent which becomes `["Apple cancel"]`.
More focus in/out clicks will keep appending ` cancel` to the form control's value.

### Expected Behavior

Not appending HTML elements' textContent to chip's form control value

### Actual Behavior

HTML element's textContent is being appended to chip's form control value

### Environment

- Angular: 15+
- CDK/Material: 15+
- Browser(s): Any browser
- Operating System (e.g. Windows, macOS, Ubuntu): Any OS

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par les fichiers de reproduction src/app/chips-autocomplete-example.html et src/app/chips-autocomplete-example.ts, puis suivez le comportement Material de blur/focusOut décrit dans l’issue. Confirmez que la perte du focus n’ajoute pas le textContent HTML imbriqué à la valeur du contrôle de formulaire du chip, y compris lorsque matChipRemove est encapsulé dans ng-container.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.