diff --git a/core/client/app/mixins/editor-base-controller.js b/core/client/app/mixins/editor-base-controller.js
index 2400c6b97d..718167d017 100644
--- a/core/client/app/mixins/editor-base-controller.js
+++ b/core/client/app/mixins/editor-base-controller.js
@@ -30,6 +30,9 @@ export default Ember.Mixin.create({
};
},
+ shouldFocusTitle: Ember.computed.alias('model.isNew'),
+ shouldFocusEditor: false,
+
autoSave: Ember.observer('model.scratch', function () {
// Don't save just because we swapped out models
if (this.get('model.isDraft') && !this.get('model.isNew')) {
@@ -229,8 +232,6 @@ export default Ember.Mixin.create({
notifications.showError(message.htmlSafe(), {delayed: delay});
},
- shouldFocusTitle: Ember.computed.alias('model.isNew'),
-
actions: {
save: function (options) {
var status,
diff --git a/core/client/app/routes/editor/edit.js b/core/client/app/routes/editor/edit.js
index 4062cf9a8f..8c46b1af40 100644
--- a/core/client/app/routes/editor/edit.js
+++ b/core/client/app/routes/editor/edit.js
@@ -6,6 +6,12 @@ import isFinite from 'ghost/utils/isFinite';
var EditorEditRoute = AuthenticatedRoute.extend(base, {
titleToken: 'Editor',
+ beforeModel: function (transition) {
+ this.set('_transitionedFromNew', transition.data.fromNew);
+
+ this._super(...arguments);
+ },
+
model: function (params) {
var self = this,
postId,
@@ -44,6 +50,12 @@ var EditorEditRoute = AuthenticatedRoute.extend(base, {
});
},
+ setupController: function (controller/*, model */) {
+ this._super(...arguments);
+
+ controller.set('shouldFocusEditor', this.get('_transitionedFromNew'));
+ },
+
actions: {
authorizationFailed: function () {
this.send('openModal', 'signin');
diff --git a/core/client/app/routes/editor/new.js b/core/client/app/routes/editor/new.js
index 9b4e908fef..055f3601f2 100644
--- a/core/client/app/routes/editor/new.js
+++ b/core/client/app/routes/editor/new.js
@@ -38,5 +38,15 @@ export default AuthenticatedRoute.extend(base, {
psm.send('resetPubDate');
this._super(controller, model);
+ },
+
+ actions: {
+ willTransition: function (transition) {
+ // decorate the transition object so the editor.edit route
+ // knows this was the previous active route
+ transition.data.fromNew = true;
+
+ this._super(...arguments);
+ }
}
});
diff --git a/core/client/app/templates/editor/edit.hbs b/core/client/app/templates/editor/edit.hbs
index 76059e9972..45b1867c21 100644
--- a/core/client/app/templates/editor/edit.hbs
+++ b/core/client/app/templates/editor/edit.hbs
@@ -27,7 +27,7 @@
- {{gh-ed-editor classNames="markdown-editor js-markdown-editor" tabindex="1" spellcheck="true" value=model.scratch setEditor="setEditor" updateScrollInfo="updateEditorScrollInfo" openModal="openModal" onFocusIn="autoSaveNew" height=height}}
+ {{gh-ed-editor classNames="markdown-editor js-markdown-editor" tabindex="1" spellcheck="true" value=model.scratch setEditor="setEditor" updateScrollInfo="updateEditorScrollInfo" openModal="openModal" onFocusIn="autoSaveNew" height=height focus=shouldFocusEditor}}