From ca19b50126e1824d8434056bfb7e13e72f932709 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Wed, 28 Nov 2018 14:17:02 +0530 Subject: [PATCH] Fix content tab redirection on campaign creation --- frontend/my/src/Campaign.js | 56 ++++++++++++++++++++------------- frontend/my/src/ModalPreview.js | 2 +- frontend/my/src/index.css | 4 +++ 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/frontend/my/src/Campaign.js b/frontend/my/src/Campaign.js index 90c3022..ef990e3 100644 --- a/frontend/my/src/Campaign.js +++ b/frontend/my/src/Campaign.js @@ -128,9 +128,12 @@ class Editor extends React.PureComponent { modules={ this.quillModules } defaultValue={ this.props.record.body } ref={ (o) => { - if(o) { - this.setState({ quill: o }) + if(!o) { + return } + + this.setState({ quill: o }) + document.querySelector(".ql-editor").focus() }} onChange={ () => { if(!this.state.quill) { @@ -218,10 +221,7 @@ class TheFormDef extends React.PureComponent { message: "Campaign created", description: `"${values["name"]}" created` }) - this.props.route.history.push(cs.Routes.ViewCampaign.replace(":id", resp.data.data.id)) - this.props.fetchRecord(resp.data.data.id) - this.props.setCurrentTab("content") - this.setState({ loading: false }) + this.props.route.history.push(cs.Routes.ViewCampaign.replace(":id", resp.data.data.id) + "#content") }).catch(e => { notification["error"]({ placement: cs.MsgPosition, message: "Error", description: e.message }) this.setState({ loading: false }) @@ -428,6 +428,11 @@ class Campaign extends React.PureComponent { } else { this.setState({ loading: false }) } + + // Content tab? + if(document.location.hash === "#content") { + this.setCurrentTab("content") + } } fetchRecord = (id) => { @@ -498,22 +503,29 @@ class Campaign extends React.PureComponent { - { - // Take the editor's reference and save it in the state - // so that it's insertMedia() function can be passed to - this.setState({ editor: e }) - }} - isSingle={ this.state.record.id ? true : false } - record={ this.state.record } - visible={ this.state.editorVisible } - toggleMedia={ this.toggleMedia } - setContent={ this.setContent } - formDisabled={ this.state.formDisabled } - /> -
-

-
+ { this.state.record.id && +
+ { + // Take the editor's reference and save it in the state + // so that it's insertMedia() function can be passed to + this.setState({ editor: e }) + }} + isSingle={ this.state.record.id ? true : false } + record={ this.state.record } + visible={ this.state.editorVisible } + toggleMedia={ this.toggleMedia } + setContent={ this.setContent } + formDisabled={ this.state.formDisabled } + /> +
+

+
+
+ } + { !this.state.record.id && + + }
diff --git a/frontend/my/src/ModalPreview.js b/frontend/my/src/ModalPreview.js index ddc6993..c92a0f3 100644 --- a/frontend/my/src/ModalPreview.js +++ b/frontend/my/src/ModalPreview.js @@ -30,7 +30,7 @@ class ModalPreview extends React.PureComponent { onOk={ this.props.onCancel }>
-