Skip to content

Commit 9b1ce0b

Browse files
committed
Only render DateTime tooltip on cell hover
1 parent 3767503 commit 9b1ce0b

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

apps/webapp/app/components/code/TSQLResultsTable.tsx

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { OutputColumnMetadata } from "@internal/clickhouse";
22
import { formatDurationMilliseconds, MachinePresetName } from "@trigger.dev/core/v3";
3+
import { useState } from "react";
34
import { EnvironmentLabel } from "~/components/environments/EnvironmentLabel";
45
import { MachineLabelCombo } from "~/components/MachineLabelCombo";
56
import { DateTimeAccurate } from "~/components/primitives/DateTime";
@@ -86,17 +87,50 @@ function isBooleanType(type: string): boolean {
8687
return type === "Bool" || type === "Nullable(Bool)";
8788
}
8889

90+
/**
91+
* Wrapper component that tracks hover state and passes it to CellValue
92+
* This optimizes rendering by only enabling tooltips when the cell is hovered
93+
*/
94+
function CellValueWrapper({
95+
value,
96+
column,
97+
prettyFormatting,
98+
}: {
99+
value: unknown;
100+
column: OutputColumnMetadata;
101+
prettyFormatting: boolean;
102+
}) {
103+
const [hovered, setHovered] = useState(false);
104+
105+
return (
106+
<span
107+
className="flex-1"
108+
onMouseEnter={() => setHovered(true)}
109+
onMouseLeave={() => setHovered(false)}
110+
>
111+
<CellValue
112+
value={value}
113+
column={column}
114+
prettyFormatting={prettyFormatting}
115+
hovered={hovered}
116+
/>
117+
</span>
118+
);
119+
}
120+
89121
/**
90122
* Render a cell value based on its type and optional customRenderType
91123
*/
92124
function CellValue({
93125
value,
94126
column,
95127
prettyFormatting = true,
128+
hovered = false,
96129
}: {
97130
value: unknown;
98131
column: OutputColumnMetadata;
99132
prettyFormatting?: boolean;
133+
hovered?: boolean;
100134
}) {
101135
// Plain text mode - render everything as monospace text with truncation
102136
if (!prettyFormatting) {
@@ -232,7 +266,7 @@ function CellValue({
232266
// DateTime types
233267
if (isDateTimeType(type)) {
234268
if (typeof value === "string") {
235-
return <DateTimeAccurate date={value} />;
269+
return <DateTimeAccurate date={value} showTooltip={hovered} />;
236270
}
237271
return <span>{String(value)}</span>;
238272
}
@@ -405,13 +439,11 @@ export function TSQLResultsTable({
405439
alignment={isRightAlignedColumn(col) ? "right" : "left"}
406440
value={valueToString(row[col.name])}
407441
>
408-
<span className="flex-1">
409-
<CellValue
410-
value={row[col.name]}
411-
column={col}
412-
prettyFormatting={prettyFormatting}
413-
/>
414-
</span>
442+
<CellValueWrapper
443+
value={row[col.name]}
444+
column={col}
445+
prettyFormatting={prettyFormatting}
446+
/>
415447
</CopyableTableCell>
416448
))}
417449
</TableRow>

0 commit comments

Comments
 (0)