Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-readers-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-dev/ui-kit": patch
---

Fix tooltip condition in ItemBase.
5 changes: 5 additions & 0 deletions .changeset/khaki-kids-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-dev/ui-kit": patch
---

Allow to rewrite the tooltip title in ItemBase.
14 changes: 5 additions & 9 deletions src/components/content/ItemBase/ItemBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ import {
Styles,
tasty,
} from '../../../tasty';
import {
mergeProps,
useCombinedRefs,
useLayoutEffect,
} from '../../../utils/react';
import { mergeProps, useCombinedRefs } from '../../../utils/react';
import {
CubeTooltipProviderProps,
TooltipProvider,
Expand Down Expand Up @@ -491,10 +487,10 @@ const ItemBase = <T extends HTMLElement = HTMLDivElement>(

// Determine if auto tooltip is enabled
const isAutoTooltipEnabled = useMemo(() => {
if (tooltip === true) return true;
if (tooltip === true && typeof children === 'string') return true;
if (typeof tooltip === 'object' && tooltip?.auto) return true;
return false;
}, [tooltip]);
}, [tooltip, typeof children]);

// Track label overflow for auto tooltip (only when enabled)
const mergedLabelRef = useCombinedRefs((labelProps as any)?.ref);
Expand All @@ -519,7 +515,7 @@ const ItemBase = <T extends HTMLElement = HTMLDivElement>(
}, [children, isAutoTooltipEnabled, checkLabelOverflow]);

useEffect(() => {
if (!isAutoTooltipEnabled || typeof children !== 'string') return;
if (!isAutoTooltipEnabled) return;

const label = mergedLabelRef.current;
if (!label) return;
Expand Down Expand Up @@ -614,7 +610,7 @@ const ItemBase = <T extends HTMLElement = HTMLDivElement>(
return (
<TooltipProvider
placement={defaultTooltipPlacement}
title={children}
title={tooltipProps.title ?? children}
{...tooltipProps}
>
{itemElement}
Expand Down
Loading