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