Skip to content

Commit

Permalink
fix: match "pointerup" listeners with "pointercancel" for full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook authored and Westbrook Johnson committed Sep 19, 2022
1 parent 962c3e8 commit 6eb873f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/button/src/ButtonBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,15 @@ export class ButtonBase extends LikeAnchor(
if (this.active) {
this.addEventListener('focusout', this.handleRemoveActive);
this.addEventListener('pointerup', this.handleRemoveActive);
this.addEventListener('pointercancel', this.handleRemoveActive);
this.addEventListener('pointerleave', this.handleRemoveActive);
} else {
this.removeEventListener('focusout', this.handleRemoveActive);
this.removeEventListener('pointerup', this.handleRemoveActive);
this.removeEventListener(
'pointercancel',
this.handleRemoveActive
);
this.removeEventListener(
'pointerleave',
this.handleRemoveActive
Expand Down
2 changes: 2 additions & 0 deletions packages/card/src/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,10 @@ export class Card extends LikeAnchor(
this.click();
}
this.removeEventListener('pointerup', handleEnd);
this.removeEventListener('pointercancel', handleEnd);
};
this.addEventListener('pointerup', handleEnd);
this.addEventListener('pointercancel', handleEnd);
}

protected get renderHeading(): TemplateResult {
Expand Down
5 changes: 5 additions & 0 deletions packages/menu/src/MenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,17 @@ export class MenuItem extends LikeAnchor(Focusable) {
if (this.active) {
this.addEventListener('pointerup', this.handleRemoveActive);
this.addEventListener('pointerleave', this.handleRemoveActive);
this.addEventListener('pointercancel', this.handleRemoveActive);
} else {
this.removeEventListener('pointerup', this.handleRemoveActive);
this.removeEventListener(
'pointerleave',
this.handleRemoveActive
);
this.removeEventListener(
'pointercancel',
this.handleRemoveActive
);
}
}
if (this.anchorElement) {
Expand Down

0 comments on commit 6eb873f

Please sign in to comment.