yangdx
commited on
Commit
·
3dc68a6
1
Parent(s):
f49f641
Optimize tooltips
Browse files
lightrag_webui/src/features/DocumentManager.tsx
CHANGED
@@ -147,16 +147,6 @@ export default function DocumentManager() {
|
|
147 |
const cardContent = cardContentRef.current;
|
148 |
if (!cardContent) return;
|
149 |
|
150 |
-
const cardRect = cardContent.getBoundingClientRect();
|
151 |
-
const cardMiddleY = cardRect.top + cardRect.height / 2;
|
152 |
-
|
153 |
-
// Get table element to check its height
|
154 |
-
const tableElement = cardContent.querySelector<HTMLElement>('table');
|
155 |
-
const tableHeight = tableElement?.offsetHeight || 0;
|
156 |
-
|
157 |
-
// Determine if table is small (less than 3 rows approximately)
|
158 |
-
const isSmallTable = tableHeight < 150;
|
159 |
-
|
160 |
// Get all visible tooltips
|
161 |
const visibleTooltips = document.querySelectorAll<HTMLElement>('.group:hover > div[class*="invisible group-hover:visible absolute"]');
|
162 |
|
@@ -167,45 +157,29 @@ export default function DocumentManager() {
|
|
167 |
|
168 |
const triggerRect = triggerElement.getBoundingClientRect();
|
169 |
|
170 |
-
//
|
171 |
-
|
172 |
-
tooltip.classList.add('tooltip-fixed');
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
if (wouldOverflowBottom) {
|
182 |
-
// Position above the trigger
|
183 |
-
tooltip.style.top = `${triggerRect.top - tooltipHeight - 5}px`;
|
184 |
-
tooltip.style.bottom = 'auto';
|
185 |
-
} else {
|
186 |
-
// Position below the trigger
|
187 |
-
tooltip.style.top = `${triggerRect.bottom + 5}px`;
|
188 |
-
tooltip.style.bottom = 'auto';
|
189 |
-
}
|
190 |
-
|
191 |
-
// Horizontal positioning
|
192 |
-
tooltip.style.left = `${triggerRect.left}px`;
|
193 |
-
tooltip.style.maxWidth = '800px';
|
194 |
|
|
|
|
|
|
|
|
|
195 |
} else {
|
196 |
-
//
|
197 |
-
tooltip.
|
198 |
-
tooltip.style.
|
199 |
-
tooltip.style.left = '';
|
200 |
-
tooltip.style.bottom = '';
|
201 |
-
|
202 |
-
// If mouse is in the bottom half of the card, show tooltip above
|
203 |
-
if (event.clientY > cardMiddleY) {
|
204 |
-
tooltip.classList.add('tooltip-top');
|
205 |
-
} else {
|
206 |
-
tooltip.classList.remove('tooltip-top');
|
207 |
-
}
|
208 |
}
|
|
|
|
|
|
|
|
|
209 |
});
|
210 |
};
|
211 |
|
@@ -384,14 +358,14 @@ export default function DocumentManager() {
|
|
384 |
{Object.entries(docs.statuses).map(([status, documents]) =>
|
385 |
documents.map((doc) => (
|
386 |
<TableRow key={doc.id}>
|
387 |
-
<TableCell className="truncate font-mono overflow-visible">
|
388 |
{showFileName ? (
|
389 |
<>
|
390 |
<div className="group relative overflow-visible tooltip-container">
|
391 |
<div className="truncate">
|
392 |
-
{getDisplayFileName(doc,
|
393 |
</div>
|
394 |
-
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[
|
395 |
{doc.file_path}
|
396 |
</div>
|
397 |
</div>
|
@@ -402,18 +376,18 @@ export default function DocumentManager() {
|
|
402 |
<div className="truncate">
|
403 |
{doc.id}
|
404 |
</div>
|
405 |
-
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[
|
406 |
{doc.file_path}
|
407 |
</div>
|
408 |
</div>
|
409 |
)}
|
410 |
</TableCell>
|
411 |
-
<TableCell className="max-w-xs min-w-
|
412 |
<div className="group relative overflow-visible tooltip-container">
|
413 |
<div className="truncate">
|
414 |
{doc.content_summary}
|
415 |
</div>
|
416 |
-
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[
|
417 |
{doc.content_summary}
|
418 |
</div>
|
419 |
</div>
|
|
|
147 |
const cardContent = cardContentRef.current;
|
148 |
if (!cardContent) return;
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
// Get all visible tooltips
|
151 |
const visibleTooltips = document.querySelectorAll<HTMLElement>('.group:hover > div[class*="invisible group-hover:visible absolute"]');
|
152 |
|
|
|
157 |
|
158 |
const triggerRect = triggerElement.getBoundingClientRect();
|
159 |
|
160 |
+
// Use fixed positioning for all tooltips
|
161 |
+
tooltip.classList.add('tooltip-fixed');
|
|
|
162 |
|
163 |
+
// Calculate position based on trigger element and mouse
|
164 |
+
const tooltipHeight = tooltip.offsetHeight;
|
165 |
+
const viewportHeight = window.innerHeight;
|
166 |
|
167 |
+
// Check if tooltip would go off the bottom of the viewport
|
168 |
+
const wouldOverflowBottom = event.clientY + tooltipHeight > viewportHeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
|
170 |
+
if (wouldOverflowBottom) {
|
171 |
+
// Position above the trigger
|
172 |
+
tooltip.style.top = `${triggerRect.top - tooltipHeight - 5}px`;
|
173 |
+
tooltip.style.bottom = 'auto';
|
174 |
} else {
|
175 |
+
// Position below the trigger
|
176 |
+
tooltip.style.top = `${triggerRect.bottom + 5}px`;
|
177 |
+
tooltip.style.bottom = 'auto';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
+
|
180 |
+
// Horizontal positioning
|
181 |
+
tooltip.style.left = `${triggerRect.left}px`;
|
182 |
+
tooltip.style.maxWidth = '600px';
|
183 |
});
|
184 |
};
|
185 |
|
|
|
358 |
{Object.entries(docs.statuses).map(([status, documents]) =>
|
359 |
documents.map((doc) => (
|
360 |
<TableRow key={doc.id}>
|
361 |
+
<TableCell className="truncate font-mono overflow-visible max-w-[200px]">
|
362 |
{showFileName ? (
|
363 |
<>
|
364 |
<div className="group relative overflow-visible tooltip-container">
|
365 |
<div className="truncate">
|
366 |
+
{getDisplayFileName(doc, 25)}
|
367 |
</div>
|
368 |
+
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[600px] whitespace-normal break-all rounded-md bg-black/95 px-3 py-2 text-sm text-white shadow-lg dark:bg-white/95 dark:text-black">
|
369 |
{doc.file_path}
|
370 |
</div>
|
371 |
</div>
|
|
|
376 |
<div className="truncate">
|
377 |
{doc.id}
|
378 |
</div>
|
379 |
+
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[600px] whitespace-normal break-all rounded-md bg-black/95 px-3 py-2 text-sm text-white shadow-lg dark:bg-white/95 dark:text-black">
|
380 |
{doc.file_path}
|
381 |
</div>
|
382 |
</div>
|
383 |
)}
|
384 |
</TableCell>
|
385 |
+
<TableCell className="max-w-xs min-w-48 truncate overflow-visible">
|
386 |
<div className="group relative overflow-visible tooltip-container">
|
387 |
<div className="truncate">
|
388 |
{doc.content_summary}
|
389 |
</div>
|
390 |
+
<div className="invisible group-hover:visible absolute z-[9999] mt-1 max-w-[600px] whitespace-normal break-all rounded-md bg-black/95 px-3 py-2 text-sm text-white shadow-lg dark:bg-white/95 dark:text-black">
|
391 |
{doc.content_summary}
|
392 |
</div>
|
393 |
</div>
|