From 97c86125f6ab08e168db3b23486a87c00c9a91fc Mon Sep 17 00:00:00 2001 From: Kulcode <152772205+jsjgdh@users.noreply.github.com> Date: Mon, 16 Feb 2026 00:23:24 +0530 Subject: [PATCH] Prevent tooltips from showing when mouse leaves the window over a widget with a tooltip (#3627) * Fix tooltip visbility issue * Reorganize * Fix --------- Co-authored-by: Keavon Chambers --- frontend/src/state-providers/tooltip.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/state-providers/tooltip.ts b/frontend/src/state-providers/tooltip.ts index e3783496..09f2fff6 100644 --- a/frontend/src/state-providers/tooltip.ts +++ b/frontend/src/state-providers/tooltip.ts @@ -55,6 +55,16 @@ export function createTooltipState(editor: Editor) { }, SHOW_TOOLTIP_DELAY_MS); }); + // Hide tooltip and cancel any pending timeout when the mouse leaves the application window + document.addEventListener("mouseleave", () => { + if (tooltipTimeout) clearTimeout(tooltipTimeout); + closeTooltip(); + }); + + document.addEventListener("mousedown", closeTooltip); + document.addEventListener("keydown", closeTooltip); + document.addEventListener("wheel", closeTooltip); + editor.subscriptions.subscribeJsMessage(SendShortcutShiftClick, async (data) => { update((state) => { state.shiftClickShortcut = data.shortcut; @@ -74,9 +84,6 @@ export function createTooltipState(editor: Editor) { }); }); - document.addEventListener("mousedown", closeTooltip); - document.addEventListener("keydown", closeTooltip); - // Stop showing a tooltip if the user clicks or presses a key, and require the user to first move out of the element before it can re-appear function closeTooltip() { update((state) => {