From 384e216e5f3fe85c131fd569ff92c8dcfb34019e Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 6 Jan 2023 01:15:45 +0100 Subject: [PATCH] Transition: Avoid possible forced layout --- src/components/ui/Transition.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/ui/Transition.tsx b/src/components/ui/Transition.tsx index 699f59d91..4f90ee4a0 100644 --- a/src/components/ui/Transition.tsx +++ b/src/components/ui/Transition.tsx @@ -237,12 +237,14 @@ const Transition: FC = ({ const container = containerRef.current!; const activeElement = container.querySelector(`.${classNames.active}`) || container.querySelector('.from'); - - if (activeElement) { - activeElement.style.height = 'auto'; - container.style.height = `${activeElement.clientHeight}px`; - container.style.flexBasis = `${activeElement.clientHeight}px`; + const clientHeight = activeElement?.clientHeight; + if (!clientHeight) { + return; } + + activeElement.style.height = 'auto'; + container.style.height = `${clientHeight}px`; + container.style.flexBasis = `${clientHeight}px`; } }, [shouldRestoreHeight, children]);