Show newly created node

This commit is contained in:
Magnus Åhall 2026-06-10 17:08:30 +02:00
parent 95a26e67d5
commit c583138270
3 changed files with 11 additions and 4 deletions

View file

@ -161,7 +161,12 @@ export class App {
return
const nn = Node.create(name, this.currentNode.UUID)
nn.save()
await nn.save()
// Treenode is forcefully rerendered and children refetched to both show the new node
// and to get it resorted.
const treenode = this.sidebar.getTreeNode(this.currentNode.UUID)
treenode.render(true, true)
}//}}}
async goToNode(nodeUUID, dontPush, dontExpand) {//{{{
if (nodeUUID === null || nodeUUID === undefined)

View file

@ -291,7 +291,6 @@ export class Node {
Name: name,
ParentUUID: parentUUID,
Markdown: false,
History: false,
})
// Newly created node (not constructed from existing data) is considered modified

View file

@ -212,6 +212,9 @@ export class N2Sidebar extends CustomHTMLElement {
isSelected(node) {//{{{
return this.selectedNode?.UUID === node.UUID
}//}}}
getTreeNode(uuid) {// {{{
return this.treeNodeComponents[uuid]
}// }}}
async keyHandler(event) {//{{{
let handled = true
@ -514,8 +517,8 @@ export class N2TreeNode extends CustomHTMLElement {
if (this.rendered && force_update !== true)
return this
if (this.sidebar.getNodeExpanded(this.node.UUID))
await this.fetchChildren()
if (this.sidebar.getNodeExpanded(this.node.UUID) || force_refetch_children)
await this.fetchChildren(force_refetch_children)
// Update the name and selected status.
this.elName.querySelector('span').innerText = this.node.get('Name')