Skip to content

Commit 73f2a55

Browse files
committed
[chrome] ux: don't restart hover time when moving from one tooltip to another
1 parent 38f657b commit 73f2a55

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

packages/chrome/src/components/TabStrip/DragTab.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { setContextMenu } from "../Menu";
44
import { iconClose, iconDuplicate, iconNew, iconRefresh } from "../../icons";
55
import { browser, forceScreenshot } from "../../Browser";
66
import { Icon } from "../Icon";
7-
import { TabTooltip } from "./TabTooltip";
7+
import { activeTooltips, TabTooltip } from "./TabTooltip";
88

99
export function DragTab(
1010
this: { tooltipActive: boolean },
@@ -92,11 +92,22 @@ export function DragTab(
9292
on:mouseenter={() => {
9393
forceScreenshot(props.tab);
9494
if (hoverTimeout) clearTimeout(hoverTimeout);
95-
hoverTimeout = window.setTimeout(() => {
95+
96+
if (activeTooltips > 0) {
97+
// skip delay
9698
this.tooltipActive = true;
97-
}, 500);
99+
} else {
100+
hoverTimeout = window.setTimeout(() => {
101+
this.tooltipActive = true;
102+
}, 500);
103+
}
98104
}}
99-
on:mouseleave={() => {
105+
on:mouseleave={(e: MouseEvent) => {
106+
const relatedTarget = e.relatedTarget as Node | null;
107+
if (relatedTarget && cx.root.contains(relatedTarget)) {
108+
// don't dismiss if hovering over the close button, even though that takes focus away from hover-area
109+
return;
110+
}
100111
if (hoverTimeout) clearTimeout(hoverTimeout);
101112
this.tooltipActive = false;
102113
}}
@@ -217,7 +228,8 @@ DragTab.style = css`
217228
border-radius: 3px;
218229
}
219230
220-
:scope:has(.hover-area:hover) .main:not(.active) {
231+
:scope:has(.hover-area:hover) .main:not(.active),
232+
:scope:has(.close:hover) .main:not(.active) {
221233
transition: background 250ms;
222234
background-color: color-mix(in srgb, currentColor 7%, transparent);
223235
/*background: var(--background_tab);*/

packages/chrome/src/components/TabStrip/TabTooltip.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { css, type ComponentContext } from "dreamland/core";
22
import type { Tab } from "../../Tab";
33
import { isFirefox } from "../../utils";
44

5+
export let activeTooltips = 0;
6+
57
export function TabTooltip(
68
props: { active: boolean; tab: Tab },
79
cx: ComponentContext
@@ -21,6 +23,7 @@ export function TabTooltip(
2123
use(props.active).listen((active) => {
2224
if (active && !wasActive) {
2325
wasActive = true;
26+
activeTooltips++;
2427
cx.root.animate([hidden, visible], {
2528
duration,
2629
fill: "forwards",
@@ -30,7 +33,9 @@ export function TabTooltip(
3033
cx.root.animate([visible, hidden], {
3134
duration,
3235
fill: "forwards",
33-
});
36+
}).onfinish = () => {
37+
activeTooltips--;
38+
};
3439
}
3540
});
3641
return (

0 commit comments

Comments
 (0)