Fix TransitionChild to preserve class while transitioning

This fixes an issue where the example component-examples/dropdown did not render the leave transition
This commit is contained in:
Ryan Gossiaux
2021-12-17 16:52:10 -08:00
parent c5ed870827
commit 993db81cfa

View File

@@ -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;
</script>
<div bind:this={container} {...$$restProps}>
<div bind:this={container} {...$$restProps} class={classes}>
{#if state === TreeStates.Visible}
<slot />
{/if}