diff --git a/website/src/lib/components/file-list/FileListNode.svelte b/website/src/lib/components/file-list/FileListNode.svelte index 8878ac39..ab225991 100644 --- a/website/src/lib/components/file-list/FileListNode.svelte +++ b/website/src/lib/components/file-list/FileListNode.svelte @@ -12,7 +12,7 @@ import { get, type Readable } from 'svelte/store'; import FileListNodeContent from './FileListNodeContent.svelte'; import FileListNodeLabel from './FileListNodeLabel.svelte'; - import { getContext, onDestroy } from 'svelte'; + import { afterUpdate, getContext } from 'svelte'; import { ListTrackSegmentItem, ListWaypointItem, @@ -46,15 +46,18 @@ : ''; const { verticalFileView } = settings; - const unsubscribe = selection.subscribe(($selection) => { + + function openIfSelectedChild() { if (collapsible && get(verticalFileView) && $selection.hasAnyChildren(item, false)) { collapsible.openNode(); } - }); + } - onDestroy(() => { - unsubscribe(); - }); + if ($selection) { + openIfSelectedChild(); + } + + afterUpdate(openIfSelectedChild); {#if node instanceof Map} diff --git a/website/src/lib/components/file-list/FileListNodeContent.svelte b/website/src/lib/components/file-list/FileListNodeContent.svelte index 0e6ca6d4..0e2bdaa9 100644 --- a/website/src/lib/components/file-list/FileListNodeContent.svelte +++ b/website/src/lib/components/file-list/FileListNodeContent.svelte @@ -198,8 +198,10 @@ }); } + let firstUpdateAfterMount = false; onMount(() => { createSortable(); + firstUpdateAfterMount = true; }); afterUpdate(() => { @@ -218,7 +220,10 @@ }); syncFileOrder(); - updateFromSelection(); + if (firstUpdateAfterMount) { + firstUpdateAfterMount = false; + updateFromSelection(); + } }); function getChangedIds() {