From becad4d7d763f43c76febd45520db97e8fac3f90 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 25 Oct 2023 22:50:32 +0200 Subject: [PATCH] FIX: do not check if inside cooked early (#24105) We already do this check inside `selectionChanged` and this was preventing us to correctly set `isSelecting` to true. This was causing issues when starting your selection from outside cooked. --- .../app/components/post-text-selection.gjs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 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 a1193e012b2..66667b22096 100644 --- a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs +++ b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs @@ -223,6 +223,10 @@ export default class PostTextSelection extends Component { @bind onSelectionChanged() { + if (this.isSelecting) { + return; + } + const { isIOS, isWinphone, isAndroid } = this.capabilities; const wait = isIOS || isWinphone || isAndroid ? INPUT_DELAY : 25; this.selectionChangeHandler = discourseDebounce( @@ -233,25 +237,13 @@ export default class PostTextSelection extends Component { } @bind - mousedown(event) { - this.validMouseDown = true; - - if (!event.target.closest(".cooked")) { - this.validMouseDown = false; - return; - } - + mousedown() { this.isSelecting = true; } @bind mouseup() { this.isSelecting = false; - - if (!this.validMouseDown) { - return; - } - this.onSelectionChanged(); }