diff --git a/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js b/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js index 1b7a3bd277555dd61dbc6c0f6fde2b4b9ca4c098..29ccb21d77b3f1c2bb8a5c09b952630e1d193024 100644 --- a/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js +++ b/app/components/SimpleEditor/elements/track_change/TrackChangeComponent.js @@ -72,9 +72,9 @@ class TrackChangeComponent extends AnnotationComponent { deleteNode(tx, { nodeId: nodeId }) if (status === 'delete') self.context.surface.delete(tx, nodeData) }) - const nextNodeData = self.buildNodeData(nextNodeId) - self.context.surface.setSelection(nextNodeData.selection) - self.context.controller.scrollTo(nextNodeId) + if (nextNodeId) { + this.focusToNext(nextNodeId) + } } rejectTrackChange () { @@ -90,9 +90,10 @@ class TrackChangeComponent extends AnnotationComponent { deleteNode(tx, { nodeId: nodeId }) if (status === 'add') self.context.surface.delete(tx, nodeData) }) - const nextNodeData = self.buildNodeData(nextNodeId) - self.context.surface.setSelection(nextNodeData.selection) - self.context.controller.scrollTo(nextNodeId) + + if (nextNodeId) { + this.focusToNext(nextNodeId) + } } buildNodeData (nodeId) { @@ -139,6 +140,12 @@ class TrackChangeComponent extends AnnotationComponent { return } + focusToNext (nextNodeId) { + const nextNodeData = this.buildNodeData(nextNodeId) + this.context.surface.setSelection(nextNodeData.selection) + this.context.controller.scrollTo(nextNodeId) + } + sortNodes (nodes) { let trackChanges = clone(nodes) const ds = this.getDocumentSession()