UX: Autofocus when input is empty.

This commit is contained in:
Guo Xiang Tan 2015-09-13 09:41:05 +08:00
parent 2ae0ef0ad9
commit c1deee772b
3 changed files with 11 additions and 2 deletions

View File

@ -9,5 +9,9 @@ export default TextField.extend({
focusIn: function() {
Em.run.later(() => { this.$().select(); });
}
},
becomeFocused: function() {
if (this.get('hasAutofocus')) this.$().focus();
}.on('didInsertElement')
});

View File

@ -13,6 +13,11 @@ export default Ember.Controller.extend({
context_id: null,
context: null,
@computed('q')
hasAutofocus(q) {
return Em.isEmpty(q);
},
@computed('skip_context', 'context')
searchContextEnabled: {
get(skip,context){

View File

@ -1,5 +1,5 @@
<div class="search row clearfix">
{{search-text-field value=searchTerm class="input-xxlarge search no-blur" action="search"}}
{{search-text-field value=searchTerm class="input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
{{d-button action="search" icon="search" class="btn-primary" disabled=isNotValidSearchTerm}}
{{#if canBulkSelect}}
{{#if model.posts}}