The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix tooltip performances (#9930)
Charles Bochetae4bf8d9298c
diff --git a/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx b/packages/twenty-ui/src/display/tooltip/AppTooltip.tsxindex e6377957f4b..39e0ea25195 100644--- a/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx+++ b/packages/twenty-ui/src/display/tooltip/AppTooltip.tsx@@ -50,6 +50,7 @@ export type AppTooltipProps = {positionStrategy?: PositionStrategy;clickable?: boolean;width?: string;+ isOpen?: boolean;};export const AppTooltip = ({@@ -65,6 +66,7 @@ export const AppTooltip = ({children,clickable,width,+ isOpen,}: AppTooltipProps) => {const delayInMs =delay === TooltipDelay.noDelay@@ -89,6 +91,7 @@ export const AppTooltip = ({children,clickable,width,+ isOpen,}}/>);diff --git a/packages/twenty-ui/src/display/tooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/display/tooltip/OverflowingTextWithTooltip.tsxindex 2d0f42899d5..18977b9a09f 100644--- a/packages/twenty-ui/src/display/tooltip/OverflowingTextWithTooltip.tsx+++ b/packages/twenty-ui/src/display/tooltip/OverflowingTextWithTooltip.tsx@@ -89,6 +89,7 @@ export const OverflowingTextWithTooltip = ({const textRef = useRef<HTMLDivElement>(null);const [isTitleOverflowing, setIsTitleOverflowing] = useState(false);+ const [shouldRenderTooltip, setShouldRenderTooltip] = useState(false);const handleMouseEnter = () => {const isOverflowing =@@ -98,10 +99,12 @@ export const OverflowingTextWithTooltip = ({: false;setIsTitleOverflowing(isOverflowing);+ setShouldRenderTooltip(true);};const handleMouseLeave = () => {setIsTitleOverflowing(false);+ setShouldRenderTooltip(false);};const handleTooltipClick = (event: React.MouseEvent<HTMLDivElement>) => {@@ -137,26 +140,29 @@ export const OverflowingTextWithTooltip = ({{text}</StyledOverflowingText>)}- {createPortal(- <div onClick={handleTooltipClick}>- <AppTooltip- anchorSelect={`#${textElementId}`}- offset={5}- hidden={!isTitleOverflowing || hideTooltip}- noArrow- place="bottom"- positionStrategy="absolute"- delay={TooltipDelay.mediumDelay}- >- {isTooltipMultiline ? (- <Styledpre>{text}</Styledpre>- ) : (- `${text || ''}`- )}- </AppTooltip>- </div>,- document.body,- )}+ {shouldRenderTooltip &&+ isTitleOverflowing &&+ createPortal(+ <div onClick={handleTooltipClick}>+ <AppTooltip+ anchorSelect={`#${textElementId}`}+ offset={5}+ hidden={!isTitleOverflowing || hideTooltip}+ noArrow+ place="bottom"+ positionStrategy="absolute"+ delay={TooltipDelay.mediumDelay}+ isOpen={true}+ >+ {isTooltipMultiline ? (+ <Styledpre>{text}</Styledpre>+ ) : (+ `${text || ''}`+ )}+ </AppTooltip>+ </div>,+ document.body,+ )}</>);};