A platform for community discussion. Free, open, simple.
FIX: prevents long press to hijack reaction event (#22021)
Joffrey JAFFEUX17e81018a2de
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbsindex 5c16e184fcb..fcfdbf47cec 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.hbs@@ -1,8 +1,8 @@{{#if (and @reaction this.emojiUrl)}}<buttontype="button"- {{on "touchstart" this.handleTouchStart}}- {{on "click" this.handleClick}}+ {{on "click" this.handleClick bubbles=false}}+ {{on "touchstart" this.handleClick bubbles=false}}tabindex="0"class={{concat-class"chat-message-reaction"diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.js b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.jsindex eb7ed845128..4c9ac1b17fc 100644--- a/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.js+++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-reaction.js@@ -45,15 +45,9 @@ export default class ChatMessageReaction extends Component {return emojiUrlFor(this.args.reaction.emoji);}- @action- handleTouchStart(event) {- this.handleClick(event);- }-@actionhandleClick(event) {event.stopPropagation();- event.preventDefault();this.args.onReaction?.(this.args.reaction.emoji,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 e978b01c8b6..397e137f956 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@@ -35,7 +35,6 @@ export default class ChatOnLongPress extends Modifier {element.addEventListener("touchstart", this.handleTouchStart, {passive: true,- capture: true,});}@@ -43,15 +42,9 @@ export default class ChatOnLongPress extends Modifier {onCancel() {cancel(this.timeout);- 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.element.removeEventListener("touchmove", this.onCancel);+ this.element.removeEventListener("touchend", this.onCancel);+ this.element.removeEventListener("touchcancel", this.onCancel);this.onLongPressCancel(this.element);}@@ -65,15 +58,9 @@ export default class ChatOnLongPress extends Modifier {this.onLongPressStart(this.element, event);- 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.element.addEventListener("touchmove", this.onCancel);+ this.element.addEventListener("touchend", this.onCancel);+ this.element.addEventListener("touchcancel", this.onCancel);this.timeout = discourseLater(() => {if (this.isDestroying || this.isDestroyed) {@@ -82,7 +69,6 @@ export default class ChatOnLongPress extends Modifier {this.element.addEventListener("touchend", cancelEvent, {once: true,- capture: true,});this.onLongPressEnd(this.element, event);