From 21cb9c6162d33176889889e57848a62b40eb5dde Mon Sep 17 00:00:00 2001 From: Thiago Sfreddo Date: Thu, 19 Feb 2026 18:23:42 -0300 Subject: [PATCH] fix dnd and improve performance Signed-off-by: Thiago Sfreddo --- ui/src/common/OverflowTooltip.jsx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ui/src/common/OverflowTooltip.jsx b/ui/src/common/OverflowTooltip.jsx index 1d05c9077..e3dca790d 100644 --- a/ui/src/common/OverflowTooltip.jsx +++ b/ui/src/common/OverflowTooltip.jsx @@ -13,17 +13,20 @@ export const OverflowTooltip = ({ const [isOverflowing, setIsOverflowing] = React.useState(false) React.useLayoutEffect(() => { - const el = textRef.current - if (!el) return + const el = textRef.current + if (!el) return - const checkOverflow = () => + const checkOverflow = () => { setIsOverflowing(el.scrollWidth > el.clientWidth) + } - checkOverflow() - window.addEventListener('resize', checkOverflow) + const resizeObserver = new ResizeObserver(checkOverflow) + resizeObserver.observe(el) - return () => window.removeEventListener('resize', checkOverflow) - }, [title, children]) + checkOverflow() + + return () => resizeObserver.disconnect() + }, [title]) return ( - {React.cloneElement(children, { ref: textRef })} + {React.cloneElement(children, { + ref: (el) => { + textRef.current = el + + const { ref } = children + if (typeof ref === 'function') { + ref(el) + } else if (ref && typeof ref === 'object') { + ref.current = el + } + }, + })} ) }