Skip to content

Commit

Permalink
fix: correctly open node from search
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinderVosDeWael committed Jul 24, 2024
1 parent 3af43b8 commit 449b7da
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/routes/templates/TemplatesDirectory/SortableNestedNode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@
import { slide } from "svelte/transition"
import type { DecisionTree } from "../DecisionTree"
import AdminButtons from "./AdminButtons.svelte"
import { openNodeIds } from "./store"
export let node: DecisionTree
export let editable = false
export let isRoot = true
let isFolded = !isRoot
let sorter: Sortable
const dispatch = createEventDispatcher()
function fold() {
if (isRoot) return
isFolded = !isFolded
if ($openNodeIds.has(node.id)) {
openNodeIds.set(new Set([...$openNodeIds].filter(id => id !== node.id)))
} else {
openNodeIds.set(new Set([...$openNodeIds, node.id]))
}
}
let isFolded = isRoot ? false : !$openNodeIds.has(node.id)
const unsubscribe = openNodeIds.subscribe(value => {
isFolded = isRoot ? false : !value.has(node.id)
})
function onSave() {
dispatch("save", { id: node.id })
dispatch("save", { node: node })
}
onMount(() => {
Expand All @@ -49,6 +57,7 @@
})
}
})
return unsubscribe
})
$: sorter?.option("disabled", !editable)
Expand Down

0 comments on commit 449b7da

Please sign in to comment.