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

Commit 7d551c3

Browse files
authored
fix(chip): Correct keyboard interaction (#1561)
Closes #1538
1 parent 14d0d8e commit 7d551c3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/chips/chip.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,10 @@ export class MdcChip implements AfterViewInit, OnDestroy {
259259
}
260260
},
261261
eventTargetHasClass: (target: HTMLElement, className: string) => target.classList.contains(className),
262-
notifyInteraction: () => this._emitSelectionChangeEvent(),
262+
notifyInteraction: () => {
263+
this.selected = !this.selected;
264+
this._emitSelectionChangeEvent();
265+
},
263266
notifyTrailingIconInteraction: () => this.trailingIconInteraction.emit({ detail: { chipId: this.id } }),
264267
notifyRemoval: () => this.removed.emit({ detail: { chipId: this.id, root: this } }),
265268
getComputedStyleValue: (propertyName: string) => {
@@ -277,7 +280,7 @@ export class MdcChip implements AfterViewInit, OnDestroy {
277280
beginExit(): void,
278281
setSelected(selected: boolean): void,
279282
setShouldRemoveOnTrailingIconClick(shouldRemove: boolean): void,
280-
handleInteraction(evt: Event): void,
283+
handleInteraction(evt: KeyboardEvent | MouseEvent): void,
281284
handleTransitionEnd(evt: TransitionEvent): void,
282285
handleTrailingIconInteraction(evt: Event): void
283286
} = new MDCChipFoundation(this.createAdapter());
@@ -319,8 +322,7 @@ export class MdcChip implements AfterViewInit, OnDestroy {
319322

320323
private _loadListeners(): void {
321324
this._chipInteractionEventSubscription = this.chipInteractionEvents.pipe()
322-
.subscribe(evt => {
323-
this.selected = !this.selected;
325+
.subscribe((evt: KeyboardEvent | MouseEvent) => {
324326
this._foundation.handleInteraction(evt);
325327
});
326328

0 commit comments

Comments
 (0)