mat-chip selected no matter what
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
[selectable]=“false” should works properly.
What is the current behavior?
[selectable]=“false” doesn’t work
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
<mat-form-field>
<mat-chip-list #phraseList class="mat-chip-list-stacked" ngDefaultControl formControlName="phrases" [selectable]="false">
<mat-chip *ngFor="let phrase of phrases.value" [selectable]="false" [selected]="false" [removable]="true" [disabled]="true">
<span fxFlex="100%">{{ phrase }}</span>
</mat-chip>
<input class="w-100" fxFlex="0%" placeholder="Phrase" [matChipInputFor]="phraseList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="true" (matChipInputTokenEnd)="addPhrase($event)" />
</mat-chip-list>
</mat-form-field>
this.form = new FormGroup({
phrases: new FormControl(new Array<string>())
});
addPhrase(e: MatChipInputEvent): void {
const input = e.input;
const value = e.value;
const phrases = this.phrases.value;
if ((value || '').trim()) {
phrases.push(value.trim());
this.phrases.setValue(phrases);
}
if (input) {
input.value = '';
}
}
get phrases() {
return this.form.get('phrases');
}
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
6.0.4
Is there anything else we should know?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Chips | Angular Material
Users can move through the chips using the arrow keys and select/deselect them with space. Chips also gain focus when clicked, ensuring keyboard...
Read more >Angular Material MatChipList does not fire change, nor select ...
Tried using (click) instead of selectionChange event and it worked. I had several similar issues while working with material components.
Read more >Chips | Angular Material
An extension of the MatChip component that supports chip selection. ... When a chip is not selectable, changes to its selected state are...
Read more >material multi select with search - You.com - You.com
I'm trying to create a custom multi select component, based on the angular-material select component (v10), with virtual-scroll and a custom search input...
Read more >Angular Material: How to Bind Chips to a Form Field
Because that's not what the docs tell you to do. Also, the form control name is added to the <mat-chip-list> element. You might...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Corsseir Could you please provide a stackblitz reproduction? I cannot reproduce this issue
[selectable]="false"
is working properly here: https://stackblitz.com/edit/angular-wcfsvk?file=app%2Fchips-input-example.html@tinayuangao This is what appears for me what I click on a chip (or tab to it) in Chrome 68.0.3440.84 and Firefox 61.0.2 for the stackblitz you provided. Toggling the selectable flag has no visual effect when selecting/de-selecting the chip.
Is
[selectable]
only supposed to cause the selected state to be ignored? Reading the documentation, it does not explicitly state that the chip will not be selectable visually, though that seems like a logical conclusion of not being selectable.