diff --git a/packages/features/timezone-buddy/components/CellHighlightContainer.tsx b/packages/features/timezone-buddy/components/CellHighlightContainer.tsx index b24bd42995..3722a7b0ed 100644 --- a/packages/features/timezone-buddy/components/CellHighlightContainer.tsx +++ b/packages/features/timezone-buddy/components/CellHighlightContainer.tsx @@ -13,20 +13,31 @@ export function CellHighlightContainer({ children }: { children: React.ReactNode const [isAnimating, setIsAnimating] = useState(false); const componentContainerRef = useRef(null); - const { x, y, height, isHover, updateDimensions, setContainerRef } = useStore(store, (state) => state); + const { x, y, height, isHover, updateDimensions, setContainerRef, browsingDate, emitCellPosition } = + useStore(store, (state) => state); + const prevBrowsingDateRef = useRef(browsingDate); useEffect(() => { let timeout: NodeJS.Timeout | null = null; if (isHover) { setIsAnimating(true); } else { - timeout = setTimeout(() => setIsAnimating(false), 1000); + timeout = setTimeout(() => setIsAnimating(false), 300); } return () => { timeout && clearTimeout(timeout); }; }, [isHover]); + useEffect(() => { + if (prevBrowsingDateRef.current?.getTime() !== browsingDate.getTime()) { + setIsAnimating(false); + // Clear hover state and position when date changes + emitCellPosition(-1); + prevBrowsingDateRef.current = browsingDate; + } + }, [browsingDate, emitCellPosition]); + useLayoutEffect(() => { const handleUpdate = () => { updateDimensions(); @@ -50,13 +61,16 @@ export function CellHighlightContainer({ children }: { children: React.ReactNode return (
{children}