From dc819877dc085273cf82b9bed4828b62092ea107 Mon Sep 17 00:00:00 2001 From: Justin Tulk Date: Thu, 30 May 2024 11:26:12 -0600 Subject: [PATCH 1/2] Removing infinite loop on modified dropdown render --- .../common/components/elements/ModifiedDropdown.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/weave-js/src/common/components/elements/ModifiedDropdown.tsx b/weave-js/src/common/components/elements/ModifiedDropdown.tsx index 16d788a1a0..900e3aba55 100644 --- a/weave-js/src/common/components/elements/ModifiedDropdown.tsx +++ b/weave-js/src/common/components/elements/ModifiedDropdown.tsx @@ -482,12 +482,15 @@ const OptionWithTooltip: React.FC = ({text}) => { const optionRef = useRef(null); useEffect(() => { - if (optionRef.current) { - setShowTooltip( - optionRef.current.scrollWidth > optionRef.current.clientWidth - ); + if (!optionRef.current) { + return; + } + const isOverflow = + optionRef.current.scrollWidth > optionRef.current.clientWidth; + if (optionRef.current && isOverflow !== showTooltip) { + setShowTooltip(isOverflow); } - }, [text]); + }, [showTooltip, text]); return (
Date: Thu, 30 May 2024 12:15:23 -0600 Subject: [PATCH 2/2] comment --- weave-js/src/common/components/elements/ModifiedDropdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weave-js/src/common/components/elements/ModifiedDropdown.tsx b/weave-js/src/common/components/elements/ModifiedDropdown.tsx index 900e3aba55..33c4f1d7cc 100644 --- a/weave-js/src/common/components/elements/ModifiedDropdown.tsx +++ b/weave-js/src/common/components/elements/ModifiedDropdown.tsx @@ -487,7 +487,7 @@ const OptionWithTooltip: React.FC = ({text}) => { } const isOverflow = optionRef.current.scrollWidth > optionRef.current.clientWidth; - if (optionRef.current && isOverflow !== showTooltip) { + if (isOverflow !== showTooltip) { setShowTooltip(isOverflow); } }, [showTooltip, text]);