Skip to content

Commit f1ac2f0

Browse files
asynclizcopybara-github
authored andcommitted
fix(ripple): remove pointerdown contextmenu bounds check for Chrome
tl;dr; the bug this check was handling is no longer reproducible in Chrome, where a `pointerdown` event would be dispatched after the user closes the `contextmenu` PiperOrigin-RevId: 791432699
1 parent 688ab3c commit f1ac2f0

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

ripple/internal/ripple.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ export class Ripple extends LitElement implements Attachable {
129129
private growAnimation?: Animation;
130130
private state = State.INACTIVE;
131131
private rippleStartEvent?: PointerEvent;
132-
private checkBoundsAfterContextMenu = false;
133132
private readonly attachableController = new AttachableController(
134133
this,
135134
this.onControlChange.bind(this),
@@ -225,15 +224,6 @@ export class Ripple extends LitElement implements Attachable {
225224
return;
226225
}
227226

228-
// after a longpress contextmenu event, an extra `pointerdown` can be
229-
// dispatched to the pressed element. Check that the down is within
230-
// bounds of the element in this case.
231-
if (this.checkBoundsAfterContextMenu && !this.inBounds(event)) {
232-
return;
233-
}
234-
235-
this.checkBoundsAfterContextMenu = false;
236-
237227
// Wait for a hold after touch delay
238228
this.state = State.TOUCH_DELAY;
239229
await new Promise((resolve) => {
@@ -280,7 +270,6 @@ export class Ripple extends LitElement implements Attachable {
280270
return;
281271
}
282272

283-
this.checkBoundsAfterContextMenu = true;
284273
this.endPressAnimation();
285274
}
286275

@@ -443,16 +432,6 @@ export class Ripple extends LitElement implements Attachable {
443432
return this.isTouch(event) || isPrimaryButton;
444433
}
445434

446-
/**
447-
* Check if the event is within the bounds of the element.
448-
*
449-
* This is only needed for the "stuck" contextmenu longpress on Chrome.
450-
*/
451-
private inBounds({x, y}: PointerEvent) {
452-
const {top, left, bottom, right} = this.getBoundingClientRect();
453-
return x >= left && x <= right && y >= top && y <= bottom;
454-
}
455-
456435
private isTouch({pointerType}: PointerEvent) {
457436
return pointerType === 'touch';
458437
}

0 commit comments

Comments
 (0)