diff --git a/src/public/javascripts/services/tree.js b/src/public/javascripts/services/tree.js index 20d555f2c..333e55bf9 100644 --- a/src/public/javascripts/services/tree.js +++ b/src/public/javascripts/services/tree.js @@ -611,7 +611,7 @@ async function createNote(node, parentNoteId, target, extraOptions) { treeCache.add(noteEntity, branchEntity); - const newNode = { + let newNode = { title: newNoteName, noteId: branchEntity.noteId, parentNoteId: parentNoteId, @@ -649,6 +649,21 @@ async function createNote(node, parentNoteId, target, extraOptions) { clearSelectedNodes(); // to unmark previously active node + // need to refresh because original doesn't have methods like .getParent() + newNode = getNodesByNoteId(branchEntity.noteId)[0]; + + // following for cycle will make sure that also clones of a parent are refreshed + for (const newParentNode of getNodesByNoteId(parentNoteId)) { + if (newParentNode.key === newNode.getParent().key) { + // we've added a note into this one so no need to refresh + continue; + } + + await newParentNode.load(true); // force reload to show up new note + + await checkFolderStatus(newParentNode); + } + return {note, branch}; }