From a32c7a8e63019da73be0e36d9f8e1553922bd6d1 Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Wed, 8 Mar 2023 18:46:50 +0900 Subject: [PATCH] Fix CodeMirror not properly sized when opening editor (#2426) * Revert "Fix open editors getting carried over to different notetypes (#2393)" This reverts commit bf5bcd3f52aadc0c5c7dda47be0bbd6a2b95b485. * Fix CodeMirror not properly sized when opening editor If the initial value of a tweened store is 'undefined' or 'null', the first value change will take effect immediately. Therefore, by setting the initial value of 'size' to 'undefined', 'collpased' will be set to 'false' with no transition time if 'false' is passed to 'collapse' prop, ensuring that CodeMirror is properly sized. --- ts/components/Collapsible.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ts/components/Collapsible.svelte b/ts/components/Collapsible.svelte index 0e8e3c0e2..c3bae9756 100644 --- a/ts/components/Collapsible.svelte +++ b/ts/components/Collapsible.svelte @@ -18,7 +18,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } $: duration = dynamicDuration(contentHeight); - const size = tweened(0); + const size = tweened(undefined); async function transition(collapse: boolean): Promise { if (collapse) { @@ -50,10 +50,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let collapsibleElement: HTMLElement; - $: collapsed = $size === 0; + $: collapsed = ($size ?? 0) === 0; $: expanded = $size === 1; - $: height = $size * contentHeight; - $: transitioning = $size > 0 && !(collapsed || expanded); + $: height = ($size ?? 0) * contentHeight; + $: transitioning = ($size ?? 0) > 0 && !(collapsed || expanded); $: measuring = !(collapsed || transitioning || expanded); let hidden = collapsed;