Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fixing run overview truncated tag tooltips on hover #3212

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
19 changes: 14 additions & 5 deletions weave-js/src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classNames from 'classnames';
import React, {FC, ReactElement, useMemo, useRef} from 'react';
import React, {FC, ReactElement, useEffect,useMemo, useRef, useState} from 'react';
import {twMerge} from 'tailwind-merge';

import {Icon, IconName} from '../Icon';
Expand Down Expand Up @@ -103,11 +103,21 @@ export const RemovableTag: FC<RemovableTagProps> = ({
Wrapper = Tailwind,
}) => {
const labelRef = useRef<HTMLParagraphElement>(null);
const isTooltipEnabled = isTagLabelTruncated(labelRef);
const [isTruncated, setIsTruncated] = useState(false);

useEffect(() => {
const checkTruncation = () => {
if (labelRef.current) {
setIsTruncated(isTagLabelTruncated(labelRef));
}
};
checkTruncation();
ArtsiomWB marked this conversation as resolved.
Show resolved Hide resolved
}, [label]);

const classes = useTagClasses({color, isInteractive: true, label});

const nakedTag = (
<TagTooltip value={label} disabled={!isTooltipEnabled}>
<TagTooltip value={label} disabled={!isTruncated}>
<div
key={`tag-${label}`}
className={twMerge(classes, showIcon ? 'px-4' : 'pl-6 pr-4')}>
Expand All @@ -132,6 +142,5 @@ export const RemovableTag: FC<RemovableTagProps> = ({
if (Wrapper) {
return <Wrapper>{nakedTag}</Wrapper>;
}

return nakedTag;
};
};
2 changes: 1 addition & 1 deletion weave-js/src/components/Tag/TagTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export const TagTooltip = React.forwardRef<HTMLElement, TagTooltipProps>(
/>
);
}
);
);
Loading