Transition: Avoid possible forced layout

This commit is contained in:
Alexander Zinchuk 2023-01-06 01:15:45 +01:00
parent f049b50e5e
commit 384e216e5f

View File

@ -237,12 +237,14 @@ const Transition: FC<TransitionProps> = ({
const container = containerRef.current!;
const activeElement = container.querySelector<HTMLDivElement>(`.${classNames.active}`)
|| container.querySelector<HTMLDivElement>('.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]);