feat(autocomplete): Multiselect (chips input)
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### Feature Description
Ability to select multiple entries from autocomplete.
https://material.angular.io/components/autocomplete/overview
### Use Case
For example when using with chips.

Btw. it would be also nice if the chip select does not wrap and scroll horizontal instead or truncate (overflow hidden) with annotation of count of additional chips like `(Chip 1) (Chip 2) +3` (means 5 chips, 2 visible, 3 hidden to prevent wrapping / changing height of input). Not tested but mabye the autocomplete select position may not updated when the input height is change while the overlay (list) is displayed.
Update: Ok this can be achieved by adding `mat-checkbox` to the options. So this feature request is maybe more about to add an example to the docs. Or what do you mean? It's maybe not that easy. The checkbox checked state must be synced with the selected chips. Also prevent closing autocomplete by click. preventDefault or stopPropagation doesn't work. etc.
https://material.angular.io/components/chips/examples
Update: Another quick solution would be to just keep the autocomplete list overlay open while click on items to add to the chip list.
Update: [Here](https://stackblitz.com/edit/angular-sx79hu-urvop3?file=app/multiselect-autocomplete-example.html) is an example. It's not from me, it's forked and might be polished. Just for inpriation. For example you need a div inside the option with click event to prevent close (stopPropagation/preventDefault). We can optimize this and add it to the examples. But since this is a little bit "hackish" we should consider to officially support this. Or give options to prevent close etc. I would not use a wrapper object for `selected` property. I would just bind checked to a method to check if value array includes item. And pointer-events none for the mat-checkbox (toggle only by option itself).
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dalla documentazione di Angular Material autocomplete e chips collegata nell’issue, quindi esamina l’esempio StackBlitz indicato. Stabilire se l’obiettivo è un comportamento di multiselezione ufficialmente supportato, un’opzione per mantenere aperto l’overlay o solo un esempio di documentazione. Il completamento dovrebbe includere un ambito concordato e l’esempio o il comportamento API corrispondente, con l’aggiornamento di test e documentazione secondo necessità.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100