A platform for community discussion. Free, open, simple.
FIX: on iOS PWA prevents touch to click (#22000)
Joffrey JAFFEUX57877fd6db45
diff --git a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js b/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.jsindex 6a0d0733dec..68ab69b28f6 100644--- a/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js+++ b/plugins/chat/assets/javascripts/discourse/modifiers/chat/on-long-press.js@@ -34,40 +34,60 @@ export default class ChatOnLongPress extends Modifier {this.onLongPressCancel = onLongPressCancel || (() => {});element.addEventListener("touchstart", this.handleTouchStart, {- passive: true,+ passive: false,+ capture: true,});}@bindonCancel() {cancel(this.timeout);- this.element.removeEventListener("touchmove", this.onCancel);- this.element.removeEventListener("touchend", this.onCancel);- this.element.removeEventListener("touchcancel", this.onCancel);++ this.element.removeEventListener("touchmove", this.onCancel, {+ capture: true,+ });+ this.element.removeEventListener("touchend", this.onCancel, {+ capture: true,+ });+ this.element.removeEventListener("touchcancel", this.onCancel, {+ capture: true,+ });+this.onLongPressCancel(this.element);}@bindhandleTouchStart(event) {if (event.touches.length > 1) {+ this.onCancel();return;}+ cancelEvent(event);+this.onLongPressStart(this.element, event);- this.element.addEventListener("touchmove", this.onCancel);- this.element.addEventListener("touchend", this.onCancel);- this.element.addEventListener("touchcancel", this.onCancel);+ this.element.addEventListener("touchmove", this.onCancel, {+ capture: true,+ });+ this.element.addEventListener("touchend", this.onCancel, {+ capture: true,+ });+ this.element.addEventListener("touchcancel", this.onCancel, {+ capture: true,+ });this.timeout = discourseLater(() => {if (this.isDestroying || this.isDestroyed) {return;}- this.onLongPressEnd(this.element, event);this.element.addEventListener("touchend", cancelEvent, {once: true,+ capture: true,});++ this.onLongPressEnd(this.element, event);}, 400);}