From 6990b38d5f0503df88c9cd7ef5646ebcb677f5e1 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 8 Aug 2014 09:30:51 -0400 Subject: [PATCH] Do not focus post title when editing. --- ghost/admin/components/gh-trim-focus-input.js | 6 +++++- ghost/admin/mixins/editor-base-controller.js | 4 ++++ ghost/admin/templates/editor/edit.hbs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ghost/admin/components/gh-trim-focus-input.js b/ghost/admin/components/gh-trim-focus-input.js index c99b19ca4a..7e9b53b30c 100644 --- a/ghost/admin/components/gh-trim-focus-input.js +++ b/ghost/admin/components/gh-trim-focus-input.js @@ -1,6 +1,10 @@ var TrimFocusInput = Ember.TextField.extend({ + focus: true, + setFocus: function () { - this.$().val(this.$().val()).focus(); + if (this.focus) { + this.$().val(this.$().val()).focus(); + } }.on('didInsertElement'), focusOut: function () { diff --git a/ghost/admin/mixins/editor-base-controller.js b/ghost/admin/mixins/editor-base-controller.js index e08f607007..db2502ddd2 100644 --- a/ghost/admin/mixins/editor-base-controller.js +++ b/ghost/admin/mixins/editor-base-controller.js @@ -184,6 +184,10 @@ var EditorControllerMixin = Ember.Mixin.create(MarkerManager, { this.notifications.showError(message, { delayed: delay }); }, + shouldFocusTitle: Ember.computed('model', function () { + return !!this.get('model.isNew'); + }), + actions: { save: function () { var status = this.get('willPublish') ? 'published' : 'draft', diff --git a/ghost/admin/templates/editor/edit.hbs b/ghost/admin/templates/editor/edit.hbs index 5340200025..d8420ef809 100644 --- a/ghost/admin/templates/editor/edit.hbs +++ b/ghost/admin/templates/editor/edit.hbs @@ -1,6 +1,6 @@
- {{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=titleScratch tabindex="1"}} + {{gh-trim-focus-input type="text" id="entry-title" placeholder="Your Post Title" value=titleScratch tabindex="1" focus=shouldFocusTitle}}