Skip to content

feat(material/chips): expose _chipGrid in MatChipInput and add a stream of chip removal events #28013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2023
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
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
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ 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;
clear(): void;
get disabled(): boolean;
set disabled(value: BooleanInput);
Expand Down Expand Up @@ -443,6 +442,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