1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00

🐛 Fixed editor autofocus when starting a new post

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
This commit is contained in:
Kevin Ansfield 2018-01-25 13:14:50 +00:00
parent 0b8aff02fb
commit 3bbd488ff2

View file

@ -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?