angular / angular/components

bug: mat-chip color is not working properly within mat-chip-list & mat-form-field

Offen
#9,851 19 Kommentare 18 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/chips needs investigation P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### Scenario

I have a simple input field that have an async autocomplete feature in order to add an email of a set of users. The added email will be illustrated in form of mat-chip within a mat-chip-list.

#### Bug
I have in my template an mat-form-field element that conatins a mat-chip-list element.
Within the mat-chip-list element i have also nested elements including the mat-chip element and an input as well as an mat-autocomplete element.

The color input of mat-chip is eql "accent", however the color is correct if i add an element to the list using the matChipInputTokenEnd event. Else, all chip's color are reset to the default one, e.g: if I add an item to the mat-chip-list using the auto complete feature...
This is very strange and therefore i provide the code and a gif below.
PS: selected input is eql `true`.

To confirm that the mat-chip works normally without the combination explained above,
i added a stand alone mat-chip (primary color - indigo) above the mat-chip-list and this works as expected. Furthermore, i added a static mat-chip ("testing") within the mat-chip-list with an accent color. This is not working too!

#### What is the expected behavior?

all chips should be with the color entered --> "accent" !!!

#### What is the current behavior?

#### What are the steps to reproduce?

```html

testing



testing


{{email}}
cancel




{{ user.email }}
({{user.displayName}})



Bitte geben Sie eine gültige E-Mail-Adresse ein




```

```ts
....
@ViewChild('emailsInput') emailsInputElement: ElementRef;

public add(event: MatChipInputEvent): void {
const input = event.input;
const value = event.value;

// Add an email
if ((value || '').trim() && this.validateEmail(value)) {
this.userEmails.push(value.trim());
this.emailsInputElement.nativeElement.value = '';
}
}

public test($event: MatAutocompleteSelectedEvent) {
console.log('on optionSelected: ', $event.option.value);
this.userEmails.push($event.option.value.trim());
this.searchValue = '';
this.emailsInputElement.nativeElement.value = '';
console.log('emails array: ', this.userEmails);
}

public remove(email: any): void {
const index = this.userEmails.indexOf(email);

if (index >= 0) {
this.userEmails.splice(index, 1);
}
}

}

```

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- Angular v5.2.3
- Material v5.1.0
- OS: MacOS high Sierra
- TS v2.4.2
- Browsers: tested on chrome and firefox (not working!)

#### Is there anything else we should know?

![feb-08-2018 22-43-04](https://user-images.githubusercontent.com/20149774/35999983-d2f2ac0c-0d21-11e8-953b-6100d8dd11c4.gif)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie damit, das gemeldete Zurücksetzen der Farbe mit dem bereitgestellten mat-chip-list-, mat-form-field-, input- und mat-autocomplete-Template unter Angular 5.2.3 und Material 5.1.0 zu reproduzieren. Verfolgen Sie die mat-chip-Farbbehandlung für Chips, die über autocomplete hinzugefügt werden, sowie für den statischen Chip, und überprüfen Sie anschließend, dass jeder Chip accent-colored bleibt, während der eigenständige Chip primary bleibt.

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
35/100

Neue Issues direkt in Ihr Postfach

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