Fixed: hasPendingChanges

Fixed: Vertical alignment changing between read/edit
This commit is contained in:
Tom Moor
2017-06-28 23:02:11 -07:00
parent 31f3d72f01
commit e40e372fed
2 changed files with 13 additions and 8 deletions

View File

@ -111,8 +111,6 @@ type KeyData = {
render = () => { render = () => {
return ( return (
<span> <span>
{!this.props.readOnly &&
<ClickablePadding onClick={this.focusAtStart} />}
<Toolbar state={this.state.state} onChange={this.onChange} /> <Toolbar state={this.state.state} onChange={this.onChange} />
<Editor <Editor
key={this.props.starred} key={this.props.starred}

View File

@ -50,7 +50,12 @@ type Props = {
loadDocument = async props => { loadDocument = async props => {
await this.props.documents.fetch(props.match.params.id); await this.props.documents.fetch(props.match.params.id);
if (this.document) this.document.view(); const document = this.document;
if (document) {
this.props.ui.setActiveDocument(document);
document.view();
}
if (this.props.match.params.edit) { if (this.props.match.params.edit) {
this.props.ui.enableEditMode(); this.props.ui.enableEditMode();
@ -71,12 +76,14 @@ type Props = {
}; };
onSave = async (redirect: boolean = false) => { onSave = async (redirect: boolean = false) => {
if (!this.document) return; const document = this.document;
await this.document.save();
if (!document) return;
await document.save();
this.props.ui.disableEditMode(); this.props.ui.disableEditMode();
if (redirect && this.document) { if (redirect) {
this.props.history.push(this.document.url); this.props.history.push(document.url);
} }
}; };
@ -90,7 +97,7 @@ type Props = {
onChange = text => { onChange = text => {
if (!this.document) return; if (!this.document) return;
this.document.updateData({ text }); this.document.updateData({ text, hasPendingChanges: true });
}; };
onCancel = () => { onCancel = () => {