diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index 5ae41caf5..6f20de93e 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -104,7 +104,7 @@ type Props = { this.props.ui.setActiveDocument(document); // Cache data if user enters edit mode and cancels this.editCache = document.text; - document.view(); + if (!this.isEditing) document.view(); // Update url to match the current one this.props.history.replace( @@ -117,6 +117,12 @@ type Props = { } }; + get isEditing() { + return ( + this.props.match.path === matchDocumentEdit || this.props.newDocument + ); + } + get document() { if (this.newDocument) return this.newDocument; return this.props.documents.getByUrl( @@ -200,7 +206,6 @@ type Props = { render() { const isNew = this.props.newDocument; const isMoving = this.props.match.path === matchDocumentMove; - const isEditing = this.props.match.path === matchDocumentEdit || isNew; const isFetching = !this.document; const titleText = get(this.document, 'title', ''); const document = this.document; @@ -231,7 +236,7 @@ type Props = { onDragEnter={this.onStartDragging} onDragLeave={this.onStopDragging} onDrop={this.onStopDragging} - disabled={isEditing} + disabled={this.isEditing} > - + {!isNew && - !isEditing && + !this.isEditing && } - {isEditing + {this.isEditing ? } - {isEditing && + {this.isEditing && Cancel } + {!this.isEditing && + + + } + {!this.isEditing && } - - - {!isEditing && } - - {!isEditing && + {!this.isEditing && New }