angular / angular/components

bug(CHIPS AUTOCOMPLETE): chips autocomplete won't emit optionSelected if matChipInputAddOnBlur is set to true

Offen
#24,855 1 Kommentar 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/chips P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### 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 creating a mat autocomplete with chips the selectedOption event is not fired if the input associated with the chip-list has the [matChipInputAddOnBlur] property set as true and has a value typed in.

if you set the matChipInputAddOnBlur to false it will work perfectly, but I also need it to fire on blur to validate or insert the inputted value.

### Reproduction

Steps to reproduce:
1. visit https://stackblitz.com/edit/angular-rmuzjg-t8dcn6?file=src/app/chips-autocomplete-example.ts
2. type "a" into the input
3. click orange (or any other option except apple)

there is a console.log('selected') in the function associated with the (optionSelected) event, it won't be fired.

### Expected Behavior

The option clicked (orange) should be added to the chips.

The autocomplete's optionSelected event should be fired.

### Actual Behavior

a chip with the value inputted is added to the chips but the option clicked is not.

the autocomplete's optionSelected event is not fired.

### Environment

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der verlinkten StackBlitz-Reproduktion und verfolge die Interaktion zwischen dem Verhalten von matChipInputAddOnBlur des Chip-Eingabefelds und dem optionSelected-Ereignis der Autovervollständigung. Überprüfe den Fall, in dem Text eingegeben und auf orange geklickt wird, und bestätige anschließend, dass die angeklickte Option hinzugefügt wird und optionSelected ausgelöst wird, während der eingegebene Wert erwartungsgemäß verarbeitet wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.