Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
fix(chips): Remove deselect from chip-set
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removes deselect() from chip-set. Update your code to use select() for toggling.

Closes #1499
  • Loading branch information
trimox committed Oct 30, 2018
1 parent b4af0c4 commit 2167c4b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
4 changes: 0 additions & 4 deletions demos/components/chips-demo/chips-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ <h2>Design & API Documentation</h2>
<td>select(chipId: string): void</td>
<td>Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.</td>
</tr>
<tr>
<td>deselect(chipId: string): void</td>
<td>Deselects the chip with the given id.</td>
</tr>
</tbody>
</table>
<table>
Expand Down
18 changes: 6 additions & 12 deletions packages/chips/chip-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,10 @@ export class MdcChipSet implements AfterContentInit, OnDestroy {
init(): void,
destroy(): void,
getSelectedChipIds(): string[],
toggleSelect(chipId: string): void,
select(chipId: string): void,
deselect(chipId: string): void
handleChipInteraction(evt: any): void,
handleChipRemoval(evt: any): void,
handleChipSelection(evt: any): void
handleChipInteraction(chipId: string): void,
handleChipRemoval(chipId: string): void,
handleChipSelection(chipId: string): void
} = new MDCChipSetFoundation(this.createAdapter());

constructor(
Expand Down Expand Up @@ -187,10 +185,6 @@ export class MdcChipSet implements AfterContentInit, OnDestroy {
this._foundation.select(chipId);
}

deselect(chipId: string): void {
this._foundation.deselect(chipId);
}

getChipById(chipId: string): MdcChip | undefined {
return this.chips.find(_ => _.id === chipId);
}
Expand Down Expand Up @@ -221,19 +215,19 @@ export class MdcChipSet implements AfterContentInit, OnDestroy {
private _listenForChipSelection(): void {
this._chipSelectionSubscription = this.chipSelections
.subscribe((event: MdcChipSelectionEvent) => {
this._foundation.handleChipSelection(event);
this._foundation.handleChipSelection(event.detail.chipId);
this.change.emit(new MdcChipSetChange(this, event.detail));
});
}

private _listenToChipsInteraction(): void {
this._chipInteractionSubscription = this.chipInteractions
.subscribe((event: MdcChipInteractionEvent) => this._foundation.handleChipInteraction(event));
.subscribe((event: MdcChipInteractionEvent) => this._foundation.handleChipInteraction(event.detail.chipId));
}

private _listenToChipsRemoved(): void {
this._chipRemoveSubscription = this.chipRemoveChanges
.subscribe((event: MdcChipRemovedEvent) => this._foundation.handleChipRemoval(event));
.subscribe((event: MdcChipRemovedEvent) => this._foundation.handleChipRemoval(event.detail.chipId));
}

private _findChipIndex(chipId: string): number {
Expand Down
6 changes: 0 additions & 6 deletions test/chips/chips.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,6 @@ describe('Chips', () => {
fixture.detectChanges();
flush();
}));

it('#should de-select chip', fakeAsync(() => {
testInstance.deselect('newsChip');
fixture.detectChanges();
flush();
}));
});
});

Expand Down

0 comments on commit 2167c4b

Please sign in to comment.