diff --git a/src/stores/annotations.ts b/src/stores/annotations.ts index 6b95e3c4..7d6d2d9c 100644 --- a/src/stores/annotations.ts +++ b/src/stores/annotations.ts @@ -212,14 +212,13 @@ export const useAnnotationsStore = defineStore('annotations', () => { } const resetAnnotations = () => { - const textPanelHtml = document.querySelector('#text-content') if (annotations.value !== null) { annotations.value.forEach((annotation) => { const selector = AnnotationUtils.generateTargetSelector(annotation); if (selector) { AnnotationUtils.highlightTargets(selector, {level: -1}); AnnotationUtils.removeIcon(annotation); - if (AnnotationUtils.isVariant(annotation) && textPanelHtml.querySelector('.witnesses')) { + if (AnnotationUtils.isVariant(annotation)) { AnnotationUtils.removeWitness(selector, annotation.body.value.witness) } } diff --git a/src/utils/annotations.js b/src/utils/annotations.js index 3b4f3f8b..adeb4396 100644 --- a/src/utils/annotations.js +++ b/src/utils/annotations.js @@ -292,6 +292,9 @@ export function removeChipsFromOtherViews() { export function removeWitness(selector, witness) { // find the witnesses span which contains each 'witness' span child element // find this witness inside the 'witnesses' html span and remove it + const textPanelHtml = document.querySelector('#text-content') + if(!textPanelHtml.querySelector('.witnesses')) return; + const witnessesHtmlEl = getWitnessesHtmlEl(selector) const witHtml = Array.from(witnessesHtmlEl.children).filter(item => item.innerHTML === witness) if (witHtml.length > 0) witHtml[0].remove()