From 4b31c233ff7d5dd6cfaacb678930f48095892e01 Mon Sep 17 00:00:00 2001 From: Anton Timmermans Date: Thu, 5 Jul 2018 11:22:32 +0200 Subject: [PATCH] Fix dirty checking --- editor/components/rich-text/annotations/annotation.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/editor/components/rich-text/annotations/annotation.js b/editor/components/rich-text/annotations/annotation.js index 937c9cf6451af..e9691ed70ab4b 100644 --- a/editor/components/rich-text/annotations/annotation.js +++ b/editor/components/rich-text/annotations/annotation.js @@ -56,6 +56,7 @@ class Annotation extends Component { startNode = this.matchEditorXPath( startXPath ); endNode = this.matchEditorXPath( endXPath ); } catch ( e ) { + console.log( "Couldn't match XPath", e ); return; } @@ -94,11 +95,13 @@ class Annotation extends Component { } static getDerivedStateFromProps( props, state ) { - const isDirty = ! isEqual( props.annotation, state.prevAnnotation ); + if ( ! isEqual( props.annotation, state.prevAnnotation ) ) { + return { + isDirty: true, + }; + } - return { - isDirty, - }; + return {}; } render() {