From 56487dd9d44b8d77ed9ead423ae29eadb1487a05 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 25 Jan 2018 13:14:50 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20editor=20autofocus=20whe?= =?UTF-8?q?n=20starting=20a=20new=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - we were setting the `shouldFocusEditor` value correctly but then immediately resetting it again 🙈 - updated the logic to change the value when going from new->edit as well as setting it correctly _after_ all of the controller values are reset in the `setPost` method --- ghost/admin/app/controllers/editor.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ghost/admin/app/controllers/editor.js b/ghost/admin/app/controllers/editor.js index 6cc474499e..6977961543 100644 --- a/ghost/admin/app/controllers/editor.js +++ b/ghost/admin/app/controllers/editor.js @@ -498,12 +498,10 @@ export default Controller.extend({ this.set('useKoenig', false); } - // autofocus the editor if we have a new post, this also acts as a - // change signal to the persistent editor on new->edit - this.set('shouldFocusEditor', post.get('isNew')); - // don't do anything else if we're setting the same post if (post === this.get('post')) { + // set autofocus as change signal to the persistent editor on new->edit + this.set('shouldFocusEditor', post.get('isNew')); return; } @@ -512,6 +510,9 @@ export default Controller.extend({ this.set('post', post); + // autofocus the editor if we have a new post + this.set('shouldFocusEditor', post.get('isNew')); + // need to set scratch values because they won't be present on first // edit of the post // TODO: can these be `boundOneWay` on the model as per the other attrs?