From 38dbb47eb06bbda31e1aa3517c3c5d95fbb938d5 Mon Sep 17 00:00:00 2001 From: Rainer Simon Date: Thu, 14 May 2020 18:56:38 +0200 Subject: [PATCH] Fixes Annotorious issue re selection equality --- src/editor/Editor.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/editor/Editor.jsx b/src/editor/Editor.jsx index 2aad0ce..0eb2efc 100644 --- a/src/editor/Editor.jsx +++ b/src/editor/Editor.jsx @@ -34,7 +34,16 @@ const Editor = props => { props.annotation.clone({ body: [ ...props.applyTemplate ]}) : props.annotation; - if (!currentAnnotation?.isEqual(annotation)) + // The 'currentAnnotation' differs from props.annotation because + // the user has been editing. Moving the selection bounds will + // trigger this effect, but we don't want to update the currentAnnotation + // on move. Therefore, don't update if a) props.annotation equals + // the currentAnnotation, or props.annotation and currentAnnotations are + // a selection, just created by the user. + const preventUpdate = currentAnnotation?.isEqual(annotation) || + (currentAnnotation?.isSelection && annotation?.isSelection); + + if (!preventUpdate) setCurrentAnnotation(annotation); if (shouldApplyTemplate && props.applyImmediately)