Browse Source

refactor: Removed dependency

rdavis 10 months ago
parent
commit
db58bb5f0f
1 changed files with 3 additions and 5 deletions
  1. 3 5
      src/lib/components/common/Collapsible.svelte

+ 3 - 5
src/lib/components/common/Collapsible.svelte

@@ -1,21 +1,19 @@
 <script lang="ts">
-	import { afterUpdate } from 'svelte';
-
 	export let open = false;
 	export let className = '';
 
 	// Manage the max-height of the collapsible content for snappy transitions
 	let contentElement: HTMLElement;
 	let maxHeight = '0px'; // Initial max-height
-	// After any state update, adjust the max-height for the transition
-	afterUpdate(() => {
+
+	$: if (contentElement?.scrollHeight) {
 		if (open) {
 			// Ensure the element is visible before measuring
 			maxHeight = `${contentElement.scrollHeight}px`;
 		} else {
 			maxHeight = '0px';
 		}
-	});
+	}
 </script>
 
 <div class={className}>