From 993db81cfa9843788b49a09eae754799de7d6f92 Mon Sep 17 00:00:00 2001 From: Ryan Gossiaux Date: Fri, 17 Dec 2021 16:52:10 -0800 Subject: [PATCH] Fix TransitionChild to preserve class while transitioning This fixes an issue where the example component-examples/dropdown did not render the leave transition --- src/lib/components/transitions/TransitionChild.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/components/transitions/TransitionChild.svelte b/src/lib/components/transitions/TransitionChild.svelte index c1259ce..feb1592 100644 --- a/src/lib/components/transitions/TransitionChild.svelte +++ b/src/lib/components/transitions/TransitionChild.svelte @@ -139,7 +139,7 @@ ); } - let _cleanup = null; + let _cleanup: (() => void) | null | undefined = null; $: { if (mounted) { if (_cleanup) { @@ -163,9 +163,13 @@ [TreeStates.Hidden]: State.Closed, }) ); + + // This is not in the base headless UI library, but is needed to prevent re-renders during the transition + // from blowing away the transition classes + $: classes = isTransitioning ? container?.className : $$props.class; -
+
{#if state === TreeStates.Visible} {/if}