Skip to content

Commit d7093ca

Browse files
committed
Dismiss Button tooltips onmousedown
Wire the Tooltip instance into Button and call dismiss on mousedown before invoking the external onmousedown handler. This prevents the tooltip from sticking or obstructing UI when the button is pressed.
1 parent 04c6a6d commit d7093ca

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/ui/src/lib/components/Button.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
tooltipDelay,
8787
tooltipMaxWidth,
8888
onclick,
89-
onmousedown,
89+
onmousedown: onmousedownExternal,
9090
oncontextmenu,
9191
onkeydown,
9292
children,
@@ -104,9 +104,16 @@
104104
}
105105
106106
const displayHotkey = $derived(hotkey ? formatHotkeyForPlatform(hotkey) : undefined);
107+
let tooltipInstance = $state<Tooltip>();
108+
109+
function onmousedown(e: MouseEvent) {
110+
tooltipInstance?.dismiss();
111+
onmousedownExternal?.(e);
112+
}
107113
</script>
108114

109115
<Tooltip
116+
bind:this={tooltipInstance}
110117
text={tooltip}
111118
align={tooltipAlign}
112119
position={tooltipPosition}

packages/ui/src/lib/components/Tooltip.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585
handleMouseLeave();
8686
}
8787
}
88+
89+
export function dismiss() {
90+
show = false;
91+
}
8892
</script>
8993

9094
{#if isTextEmpty}

0 commit comments

Comments
 (0)