Skip to content

Commit 3767503

Browse files
committed
Only render the header Tooltip components when it's being hovered
1 parent 9b81c41 commit 3767503

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

apps/webapp/app/components/primitives/Table.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellP
157157
break;
158158
}
159159

160+
const [isHovered, setIsHovered] = useState(false);
161+
160162
return (
161163
<th
162164
ref={ref}
@@ -168,6 +170,8 @@ export const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellP
168170
)}
169171
colSpan={colSpan}
170172
tabIndex={-1}
173+
onMouseEnter={() => setIsHovered(true)}
174+
onMouseLeave={() => setIsHovered(false)}
171175
>
172176
{hiddenLabel ? (
173177
<span className="sr-only">{children}</span>
@@ -179,7 +183,11 @@ export const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellP
179183
})}
180184
>
181185
{children}
182-
<InfoIconTooltip content={tooltip} contentClassName="normal-case tracking-normal" />
186+
<InfoIconTooltip
187+
content={tooltip}
188+
contentClassName="normal-case tracking-normal"
189+
enabled={isHovered}
190+
/>
183191
</div>
184192
) : (
185193
children

apps/webapp/app/components/primitives/Tooltip.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,23 @@ export function InfoIconTooltip({
113113
contentClassName,
114114
variant = "basic",
115115
disableHoverableContent = false,
116+
enabled = true,
116117
}: {
117118
content: React.ReactNode;
118119
buttonClassName?: string;
119120
contentClassName?: string;
120121
variant?: Variant;
121122
disableHoverableContent?: boolean;
123+
enabled?: boolean;
122124
}) {
125+
const icon = (
126+
<InformationCircleIcon className={cn("size-3.5 text-text-dimmed", buttonClassName)} />
127+
);
128+
129+
if (!enabled) return icon;
123130
return (
124131
<SimpleTooltip
125-
button={
126-
<InformationCircleIcon className={cn("size-3.5 text-text-dimmed", buttonClassName)} />
127-
}
132+
button={icon}
128133
content={content}
129134
variant={variant}
130135
className={contentClassName}

0 commit comments

Comments
 (0)