Skip to content

Commit 29b14ff

Browse files
fix: tooltip works only the first time (#269)
* fix: changed tooltip behaviour updated the stateSignal value inside showTooltip function * fix(tooltip.tsx): fixed first time tooltip position while hovering for the first time, the tooltip position was wrong. * fix: changed default state for stateSignal to closing
1 parent 4d2e53b commit 29b14ff

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/headless/src/components/tooltip/tooltip.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const Tooltip = component$(
2727
const id = useId();
2828
const triggerAnchor = useSignal<HTMLElement>();
2929
const tooltipAnchor = useSignal<HTMLElement>();
30-
const stateSignal = useSignal<State>('hidden');
30+
const stateSignal = useSignal<State>('closing');
3131
const positionSignal = useSignal<{ x: number; y: number }>({ x: 0, y: 0 });
3232
const Wrapper: keyof HTMLElementTagNameMap = props.inline ? 'span' : 'div';
3333
const lastActivatedTimestamp = useSignal<number>(Date.now());
@@ -54,7 +54,8 @@ export const Tooltip = component$(
5454
});
5555

5656
const showTooltip = $(() => {
57-
stateSignal.value = 'unpositioned';
57+
update();
58+
setTimeout(() => (stateSignal.value = 'positioned'), durationMs);
5859
});
5960

6061
const hideTooltip = $(() => {

0 commit comments

Comments
 (0)