Skip to content

Commit

Permalink
feat(material/chips): expose _chipGrid in MatChipInput and add a stre…
Browse files Browse the repository at this point in the history
…am of chip removal events (angular#28012)
  • Loading branch information
clamli committed Oct 27, 2023
1 parent 17ea8e7 commit 023c0a9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/material/chips/chip-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha

/** Whether the control is focused. */
focused: boolean = false;
_chipGrid: MatChipGrid;

/** Register input for chip list */
@Input('matChipInputFor')
get chipGrid(): MatChipGrid {
return this._chipGrid;
}
set chipGrid(value: MatChipGrid) {
if (value) {
this._chipGrid = value;
this._chipGrid.registerInput(this);
}
}
private _chipGrid: MatChipGrid;

/**
* Whether or not the chipEnd event will be emitted when the input is blurred.
Expand Down
7 changes: 6 additions & 1 deletion src/material/chips/chip-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ export class MatChipSet
return this._getChipStream(chip => chip._onFocus);
}

/** Combined stream of all of the child chips' remove events. */
/** Combined stream of all of the child chips' destroy events. */
get chipDestroyedChanges(): Observable<MatChipEvent> {
return this._getChipStream(chip => chip.destroyed);
}

/** Combined stream of all of the child chips' remove events. */
get chipRemovedChanges(): Observable<MatChipEvent> {
return this._getChipStream(chip => chip.removed);
}

/** Whether the chip set is disabled. */
@Input()
get disabled(): boolean {
Expand Down
2 changes: 2 additions & 0 deletions tools/public_api_guard/material/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha
_addOnBlur: boolean;
_blur(): void;
readonly chipEnd: EventEmitter<MatChipInputEvent>;
get chipGrid(): MatChipGrid;
set chipGrid(value: MatChipGrid);
// (undocumented)
_chipGrid: MatChipGrid;
Expand Down Expand Up @@ -443,6 +444,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterViewInit, H
_chipActions: QueryList<MatChipAction>;
get chipDestroyedChanges(): Observable<MatChipEvent>;
get chipFocusChanges(): Observable<MatChipEvent>;
get chipRemovedChanges(): Observable<MatChipEvent>;
_chips: QueryList<MatChip>;
protected _defaultRole: string;
protected _destroyed: Subject<void>;
Expand Down

0 comments on commit 023c0a9

Please sign in to comment.