From ed443721fc3742c36778ca1a8740a8926315b5be Mon Sep 17 00:00:00 2001 From: Juned Chhipa Date: Tue, 20 Aug 2024 15:53:53 +0530 Subject: [PATCH] fix #4644; clearAnnotations fix --- src/modules/annotations/Annotations.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/annotations/Annotations.js b/src/modules/annotations/Annotations.js index 98f1f0438..c206f596a 100644 --- a/src/modules/annotations/Annotations.js +++ b/src/modules/annotations/Annotations.js @@ -286,11 +286,14 @@ export default class Annotations { ) // annotations added externally should be cleared out too - w.globals.memory.methodsToExec.map((m, i) => { - if (m.label === 'addText' || m.label === 'addAnnotation') { + for (let i = w.globals.memory.methodsToExec.length - 1; i >= 0; i--) { + if ( + w.globals.memory.methodsToExec[i].label === 'addText' || + w.globals.memory.methodsToExec[i].label === 'addAnnotation' + ) { w.globals.memory.methodsToExec.splice(i, 1) } - }) + } annos = Utils.listToArray(annos)