diff --git a/packages/web/components/templates/article/PdfArticleContainer.tsx b/packages/web/components/templates/article/PdfArticleContainer.tsx index 08bcdceb2..2449a0d7a 100644 --- a/packages/web/components/templates/article/PdfArticleContainer.tsx +++ b/packages/web/components/templates/article/PdfArticleContainer.tsx @@ -136,14 +136,25 @@ export default function PdfArticleContainer( id: 'tooltip-remove-annotation', className: 'TooltipItem-Remove', onPress: () => { + const annotationId = annotationOmnivoreId(annotation) + instance .delete(annotation) .then(() => { - const annotationId = annotationOmnivoreId(annotation) if (annotationId) { return deleteHighlightMutation(annotationId) } }) + .then(() => { + const highlightIdx = highlightsRef.current.findIndex( + (value) => { + return value.id == annotationId + } + ) + if (highlightIdx > -1) { + highlightsRef.current.splice(highlightIdx, 1) + } + }) .catch((err) => { showErrorToast('Error deleting highlight: ' + err) })