Fix three layers of safeguards to ensure node doesn't become it's own parent

This commit is contained in:
Magnus Åhall 2026-06-15 16:39:56 +02:00
parent 960c9e2625
commit edd3d11b09
3 changed files with 143 additions and 7 deletions

View file

@ -598,15 +598,25 @@ export class N2TreeNode extends CustomHTMLElement {
e.preventDefault()
}// }}}
async dragDrop(e) {// {{{
e.stopPropagation()
const sourceNode = _app.dragIcon.getSource()
await _app.moveNode(sourceNode.node, this.node.UUID)
try {
e.stopPropagation()
const sourceNode = _app.dragIcon.getSource()
_app.sidebar.setNodeExpanded(this, true)
await this.render(true, true)
await sourceNode.render(true, true)
// Abort if user drops the node back on itself.
if (sourceNode.node.UUID === this.node.UUID)
return
this.dragLeave(e)
await _app.moveNode(sourceNode.node, this.node.UUID)
_app.sidebar.setNodeExpanded(this, true)
await this.render(true, true)
await sourceNode.render(true, true)
} catch (e) {
console.error(e)
alert(e)
} finally {
this.dragLeave(e)
}
}// }}}
dragEnter(e) {// {{{
const targetNode = e.target.closest('n2-treenode')