From fe68f8f4c6c69ca1ad8dff630b164eafc8efd0fb Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Fri, 22 Nov 2024 17:29:15 +0700 Subject: [PATCH] UBERF-8600 Fix toolbar disappearing on click (#7223) Signed-off-by: Alexander Onnikov --- .../src/components/TextEditorToolbar.svelte | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/text-editor-resources/src/components/TextEditorToolbar.svelte b/plugins/text-editor-resources/src/components/TextEditorToolbar.svelte index c51d60533c..97158ff4e7 100644 --- a/plugins/text-editor-resources/src/components/TextEditorToolbar.svelte +++ b/plugins/text-editor-resources/src/components/TextEditorToolbar.svelte @@ -97,7 +97,7 @@ let selecting = false - function handleMouseDown (): void { + function handleMouseDown (event: MouseEvent): void { function handleMouseMove (): void { if (editor !== undefined && !editor.state.selection.empty) { selecting = true @@ -112,9 +112,11 @@ document.removeEventListener('mouseup', handleMouseUp) } - if (editor !== undefined) { - document.addEventListener('mousemove', handleMouseMove) - document.addEventListener('mouseup', handleMouseUp) + if (editor !== undefined && visible && visibleActions.length > 0) { + if (event.target !== null && toolbar !== null && !toolbar.contains(event.target as Node)) { + document.addEventListener('mousemove', handleMouseMove) + document.addEventListener('mouseup', handleMouseUp) + } } }