diff --git a/public/app/features/logs/components/panel/LogLine.tsx b/public/app/features/logs/components/panel/LogLine.tsx index fce21d6c4a0..7b36cfdc737 100644 --- a/public/app/features/logs/components/panel/LogLine.tsx +++ b/public/app/features/logs/components/panel/LogLine.tsx @@ -149,11 +149,21 @@ const LogLineComponent = memo( if (!logLineRef.current) { return; } - const observer = new ResizeObserver(() => { - handleLogLineResize(); - }); + let frameId: number; + const handleResize = () => { + if (frameId) { + cancelAnimationFrame(frameId); + } + frameId = requestAnimationFrame(() => handleLogLineResize()); + }; + const observer = new ResizeObserver(handleResize); observer.observe(logLineRef.current); - return () => observer.disconnect(); + return () => { + observer.disconnect(); + if (frameId) { + cancelAnimationFrame(frameId); + } + } }, [handleLogLineResize]); useEffect(() => {