"annotationChanged" event is triggered 4 times when i move a stamp to another page

Which product are you using?
PDF.js Express Plus

PDF.js Express Version
8.7.5

Detailed description of issue
I use a custom stamp. I also have an eventListener on ‘annotationChanged’. If I move the stamp from one page to another using drag & drop, the event listener ‘annotationChanged’ is triggered once with the action ‘delete’, once with the action ‘add’ and twice with the action ‘modify’.

Also, in the case of the ‘delete’ action, for example, the property IsDeleted is not set to true. The same applies to IsAdded and IsModified for the other two actions.

Expected behaviour
When the stamp is moved to another page, only the ‘modify’ action is triggered and the IsModified is set to true.

Does your issue happen with every document, or just one?
every

Link to document
annotationChanged documentation

Code snippet
annotationManager.addEventListener(‘annotationChanged’, (annotations, action, { source }) => {
console.log(‘annotationChanged’, action, source)

if (action == ‘add’) {
annotations.forEach((annotation) => {
console.log(‘add’, annotation.IsAdded, annotation)
})
}

if (action == ‘modify’) {
annotations.forEach((annotation) => {
console.log(‘modify’, annotation.Id, annotation.IsModified, annotation)
})
}

if (action == ‘delete’) {
annotations.forEach((annotation) => {
console.log(‘delete’, annotation.Id, annotation.IsDeleted, annotation)
// const { signatureId, id } = this.extractDataFromAnnotation(annotation)
// this.api.destroy(signatureId, id)
})
}
});

Hello invoices,

This is actually expected, since technically the PDF specification does not allow annotations to be moved between pages. To get around this we create a copy of the annotation to the next page, delete the original, then modify the properties so it appears exactly like the deleted one.

Best regards,
Tyler