From b5c565228714f7ddb98320a4e4bede91abff512f Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Thu, 4 Apr 2024 00:24:30 +0200 Subject: [PATCH] only unmount if we are not transitioning ourselves --- .../src/components/transition/transition.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/@headlessui-react/src/components/transition/transition.tsx b/packages/@headlessui-react/src/components/transition/transition.tsx index e3ab1c6743..a4647372b2 100644 --- a/packages/@headlessui-react/src/components/transition/transition.tsx +++ b/packages/@headlessui-react/src/components/transition/transition.tsx @@ -385,14 +385,18 @@ function TransitionChildFn { - // When all children have been unmounted we can only hide ourselves if and only if we are not - // transitioning ourselves. Otherwise we would unmount before the transitions are finished. + // When all children have been unmounted we can only hide ourselves if and + // only if we are not transitioning ourselves. Otherwise we would unmount + // before the transitions are finished. + if (isTransitioning.current) return + setState(TreeStates.Hidden) unregister(container) }, parentNesting) - let isTransitioning = useRef(false) useTransition({ container, classes, @@ -406,8 +410,8 @@ function TransitionChildFn