diff --git a/core/client/components/gh-trim-focus-input.js b/core/client/components/gh-trim-focus-input.js index c99b19ca4a..7e9b53b30c 100644 --- a/core/client/components/gh-trim-focus-input.js +++ b/core/client/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/core/client/mixins/editor-base-controller.js b/core/client/mixins/editor-base-controller.js index e08f607007..db2502ddd2 100644 --- a/core/client/mixins/editor-base-controller.js +++ b/core/client/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/core/client/templates/editor/edit.hbs b/core/client/templates/editor/edit.hbs index 5340200025..d8420ef809 100644 --- a/core/client/templates/editor/edit.hbs +++ b/core/client/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}}