From d7b7ca82f524f23a6a1bd507f70e6a0e537f5857 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 13 Jul 2023 13:31:53 +0200 Subject: [PATCH] FIX: show only context menu on img long press (#22589) Prior to this commit a long press on the image of a chat message would trigger both the actions menu and the contextual menu. This commit ensures we only show the contextual menu in this case. No test as it's a quite complex behavior to reproduce (would need android for example). --- .../javascripts/discourse/components/chat-message.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.js b/plugins/chat/assets/javascripts/discourse/components/chat-message.js index b2e6d09abac..4de0a790ad9 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.js @@ -281,11 +281,15 @@ export default class ChatMessage extends Component { } @action - onLongPressStart() { + onLongPressStart(element, event) { if (!this.args.message.expanded) { return; } + if (event.target.tagName === "IMG") { + return; + } + // prevents message to show as active when starting scroll // at this moment scroll has no momentum and the row can // capture the touch event instead of a scroll @@ -312,7 +316,11 @@ export default class ChatMessage extends Component { } @action - onLongPressEnd() { + onLongPressEnd(element, event) { + if (event.target.tagName === "IMG") { + return; + } + cancel(this._makeMessageActiveHandler); this.isActive = false;