Skip to content

Commit 9e66c42

Browse files
committed
Fix: TypeError null from offsetWidth
1 parent b8359e1 commit 9e66c42

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/shared/ui/tooltip.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,21 @@ function AnimatedTooltipComponent({
6060
// Use currentTarget (which is correctly typed) instead of target to avoid TS2339
6161
const handleMouseMove = (event: React.MouseEvent<HTMLImageElement>) => {
6262
if (!isClient) return;
63+
64+
const target = event.currentTarget;
65+
const halfWidth = target.offsetWidth / 2;
66+
const offsetX = event.nativeEvent.offsetX;
67+
6368
if (animationFrameRef.current) {
6469
cancelAnimationFrame(animationFrameRef.current);
6570
}
71+
6672
animationFrameRef.current = requestAnimationFrame(() => {
67-
const halfWidth = event.currentTarget.offsetWidth / 2;
68-
x.set(event.nativeEvent.offsetX - halfWidth);
73+
x.set(offsetX - halfWidth);
6974
});
7075
};
7176

72-
77+
7378
const getPositionClasses = () => {
7479
switch (position) {
7580
case 'top':

0 commit comments

Comments
 (0)