Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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
6 changes: 5 additions & 1 deletion src/components/EllipsisTooltip/EllipsisTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface DialEllipsisTooltipProps extends DialTooltipContainerOptions {
contentClassName?: string;
hideTooltip?: boolean;
id?: string;
customTooltipContent?: ReactNode;
}

/**
Expand All @@ -37,6 +38,7 @@ export interface DialEllipsisTooltipProps extends DialTooltipContainerOptions {
* @param contentClassName Optional additional CSS classes for the tooltip content.
* @param hideTooltip If true, disables the tooltip even if text is truncated.
* @param id Optional attribute for unique identification
* @param customTooltipContent If provided, this content will be shown in the tooltip instead of the full text when truncated.
* @param tooltipProps Additional props to pass to the underlying DialTooltipContainer.
*/
export const DialEllipsisTooltip: FC<DialEllipsisTooltipProps> = ({
Expand All @@ -45,6 +47,7 @@ export const DialEllipsisTooltip: FC<DialEllipsisTooltipProps> = ({
contentClassName,
hideTooltip,
id,
customTooltipContent,
...tooltipProps
}) => {
const ref = useRef<HTMLElement | null>(null);
Expand Down Expand Up @@ -94,8 +97,9 @@ export const DialEllipsisTooltip: FC<DialEllipsisTooltipProps> = ({

const tooltipContent = useMemo(() => {
if (hideTooltip) return '';
if (customTooltipContent) return customTooltipContent;
return isTruncated ? fullText : '';
}, [fullText, hideTooltip, isTruncated]);
}, [customTooltipContent, fullText, hideTooltip, isTruncated]);

return (
<DialTooltipContainer {...tooltipProps}>
Expand Down
Loading
Loading