Skip to content

Commit

Permalink
fix(#4): 🐛 address NotFoundError
Browse files Browse the repository at this point in the history
This fix solves the NotFoundError, throwed whenever there was an attempt of removing an already removed target
  • Loading branch information
franmagn committed Oct 14, 2025
1 parent 94a7959 commit 939af8d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/AnnotationControl/annotationPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,23 @@ export function initAnnotationsPanel(viewer) {
ev.stopPropagation()
startInlineEditForUUID(uuid)
})
input.replaceWith(newLabel)
// The input may have been removed already by an external update.
// Check connectivity before replacing to avoid DOMNotFound errors.
try {
if (input.isConnected) {
input.replaceWith(newLabel)
} else {
// If input no longer in DOM, ensure any existing label is updated instead
const existing = targetContainer.querySelector(`.annotation-label[data-uuid="${uuid}"]`)
if (existing) existing.textContent = newText
}
} catch (e) {
// ignore DOM replacement errors and try to update label if present
try {
const existing = targetContainer.querySelector(`.annotation-label[data-uuid="${uuid}"]`)
if (existing) existing.textContent = newText
} catch (_) {}
}
// commit to jsTree and live annotation
_commitEditedName(uuid, newText)
}
Expand Down

0 comments on commit 939af8d

Please sign in to comment.