From a32fa3b9470dde0543fcee809f2abd1f219f7336 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 12 Sep 2023 18:49:06 +0200 Subject: [PATCH] FIX: cancel post toolbar on click outside (#23546) On `mousedown` if the click is outside a cooked element cancel the `mousedown`/`mouseup` sequence and only rely on the `selectionchange` event. This change ensures a click on avatar for example will work, even if user is doing a rather slow click (meaning: the mousedown has been hold for more than 100ms). --- .../discourse/app/components/post-text-selection.gjs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs index 8165bde932d..47a6ea59776 100644 --- a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs +++ b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs @@ -233,9 +233,14 @@ export default class PostTextSelection extends Component { } @bind - async mousedown() { - this.isMousedown = true; + mousedown(event) { this.holdingMouseDown = false; + + if (!event.target.closest(".cooked")) { + return; + } + + this.isMousedown = true; this.holdingMouseDownHandler = discourseLater(() => { this.holdingMouseDown = true; }, 100);