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

Commit

Permalink
fix(chip): Correct keyboard interaction (#1561)
Browse files Browse the repository at this point in the history
Closes #1538
  • Loading branch information
trimox authored Nov 22, 2018
1 parent 14d0d8e commit 7d551c3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ export class MdcChip implements AfterViewInit, OnDestroy {
}
},
eventTargetHasClass: (target: HTMLElement, className: string) => target.classList.contains(className),
notifyInteraction: () => this._emitSelectionChangeEvent(),
notifyInteraction: () => {
this.selected = !this.selected;
this._emitSelectionChangeEvent();
},
notifyTrailingIconInteraction: () => this.trailingIconInteraction.emit({ detail: { chipId: this.id } }),
notifyRemoval: () => this.removed.emit({ detail: { chipId: this.id, root: this } }),
getComputedStyleValue: (propertyName: string) => {
Expand All @@ -277,7 +280,7 @@ export class MdcChip implements AfterViewInit, OnDestroy {
beginExit(): void,
setSelected(selected: boolean): void,
setShouldRemoveOnTrailingIconClick(shouldRemove: boolean): void,
handleInteraction(evt: Event): void,
handleInteraction(evt: KeyboardEvent | MouseEvent): void,
handleTransitionEnd(evt: TransitionEvent): void,
handleTrailingIconInteraction(evt: Event): void
} = new MDCChipFoundation(this.createAdapter());
Expand Down Expand Up @@ -319,8 +322,7 @@ export class MdcChip implements AfterViewInit, OnDestroy {

private _loadListeners(): void {
this._chipInteractionEventSubscription = this.chipInteractionEvents.pipe()
.subscribe(evt => {
this.selected = !this.selected;
.subscribe((evt: KeyboardEvent | MouseEvent) => {
this._foundation.handleInteraction(evt);
});

Expand Down

0 comments on commit 7d551c3

Please sign in to comment.