From b8b25baf5c645afd8e0fd93f5fa649059c2759a8 Mon Sep 17 00:00:00 2001 From: SujalXplores Date: Mon, 25 Nov 2024 20:46:17 +0530 Subject: [PATCH] refactor: improve history item hover states and interactions --- app/components/sidebar/HistoryItem.tsx | 93 +++++++++----------------- 1 file changed, 30 insertions(+), 63 deletions(-) diff --git a/app/components/sidebar/HistoryItem.tsx b/app/components/sidebar/HistoryItem.tsx index 3f58735f8..4c284359d 100644 --- a/app/components/sidebar/HistoryItem.tsx +++ b/app/components/sidebar/HistoryItem.tsx @@ -1,5 +1,4 @@ import * as Dialog from '@radix-ui/react-dialog'; -import { useEffect, useRef, useState } from 'react'; import { type ChatHistoryItem } from '~/lib/persistence'; import WithTooltip from '~/components/ui/Tooltip'; @@ -11,78 +10,46 @@ interface HistoryItemProps { } export function HistoryItem({ item, onDelete, onDuplicate, exportChat }: HistoryItemProps) { - const [hovering, setHovering] = useState(false); - const hoverRef = useRef(null); - - useEffect(() => { - let timeout: NodeJS.Timeout | undefined; - - function mouseEnter() { - setHovering(true); - - if (timeout) { - clearTimeout(timeout); - } - } - - function mouseLeave() { - setHovering(false); - } - - hoverRef.current?.addEventListener('mouseenter', mouseEnter); - hoverRef.current?.addEventListener('mouseleave', mouseLeave); - - return () => { - hoverRef.current?.removeEventListener('mouseenter', mouseEnter); - hoverRef.current?.removeEventListener('mouseleave', mouseLeave); - }; - }, []); - return ( -
+
{item.description}
- {hovering && ( -
- +
+ +
- )} + +