diff --git a/lightrag_webui/src/features/DocumentManager.tsx b/lightrag_webui/src/features/DocumentManager.tsx index 9d070224..46ad2692 100644 --- a/lightrag_webui/src/features/DocumentManager.tsx +++ b/lightrag_webui/src/features/DocumentManager.tsx @@ -47,14 +47,6 @@ const getDisplayFileName = (doc: DocStatusResponse, maxLength: number = 20): str }; const pulseStyle = ` -/* Custom tooltip styles */ -.tooltip-top { - bottom: 100% !important; - top: auto !important; - margin-bottom: 0.25rem !important; - margin-top: 0 !important; -} - /* Fixed tooltip styles for small tables */ .tooltip-fixed { position: fixed !important; @@ -142,13 +134,21 @@ export default function DocumentManager() { useEffect(() => { if (!docs) return; - // Function to handle mouse movement - const handleMouseMove = (event: MouseEvent) => { + // Function to handle mouse movement - throttled to reduce layout calculations + let lastExecution = 0; + const throttleInterval = 50; // ms + + const handleMouseMove = () => { + const now = Date.now(); + if (now - lastExecution < throttleInterval) return; + lastExecution = now; + const cardContent = cardContentRef.current; if (!cardContent) return; // Get all visible tooltips const visibleTooltips = document.querySelectorAll('.group:hover > div[class*="invisible group-hover:visible absolute"]'); + if (visibleTooltips.length === 0) return; visibleTooltips.forEach(tooltip => { // Get the parent element that triggered the tooltip @@ -160,12 +160,12 @@ export default function DocumentManager() { // Use fixed positioning for all tooltips tooltip.classList.add('tooltip-fixed'); - // Calculate position based on trigger element and mouse + // Calculate position based on trigger element const tooltipHeight = tooltip.offsetHeight; const viewportHeight = window.innerHeight; // Check if tooltip would go off the bottom of the viewport - const wouldOverflowBottom = event.clientY + tooltipHeight > viewportHeight; + const wouldOverflowBottom = triggerRect.bottom + tooltipHeight + 5 > viewportHeight; if (wouldOverflowBottom) { // Position above the trigger @@ -273,7 +273,7 @@ export default function DocumentManager() { {t('documentPanel.documentManager.title')} - +
)}