Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/material-experimental/mdc-chips/chip-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn
set value(value: any) {
this._value = value;
}
protected _value: any;
protected _value: Array<any> = [];

/** Combined stream of all of the child chips' blur events. */
get chipBlurChanges(): Observable<MatChipEvent> {
Expand Down Expand Up @@ -478,9 +478,9 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn
}

/** Emits change event to set the model value. */
private _propagateChanges(fallbackValue?: any): void {
private _propagateChanges(): void {
const valueToEmit = this._chips.length ? this._chips.toArray().map(
chip => chip.value) : fallbackValue;
chip => chip.value) : [];
this._value = valueToEmit;
this.change.emit(new MatChipGridChange(this, valueToEmit));
this.valueChange.emit(valueToEmit);
Expand Down
7 changes: 4 additions & 3 deletions src/material-experimental/mdc-chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
}
protected _disabled: boolean = false;

private _textElement!: HTMLElement;

/** The value of the chip. Defaults to the content inside `<mat-chip>` tags. */
/** The value of the chip. Defaults to the content inside the mdc-chip__text element. */
@Input()
get value(): any {
return this._value !== undefined
? this._value
: this._elementRef.nativeElement.textContent;
: this._textElement.textContent!.trim();
}
set value(value: any) { this._value = value; }
protected _value: any;
Expand Down Expand Up @@ -321,7 +322,6 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte
this._animationsDisabled = animationMode === 'NoopAnimations';
this._isBasicChip = _elementRef.nativeElement.hasAttribute(this.basicChipAttrName) ||
_elementRef.nativeElement.tagName.toLowerCase() === this.basicChipAttrName;

}

ngAfterContentInit() {
Expand All @@ -330,6 +330,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte

ngAfterViewInit() {
this._chipFoundation.init();
this._textElement = this._elementRef.nativeElement.querySelector('.mdc-chip__text');
}

ngOnDestroy() {
Expand Down