From 2ae0ef0ad92a585c2c28b8d79f39b620506a2551 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Sat, 12 Sep 2015 14:06:46 +0800 Subject: [PATCH] UX: Select search term when focus returns to search box. --- .../javascripts/discourse/components/search-menu.js.es6 | 2 +- .../javascripts/discourse/components/search-text-field.js.es6 | 4 ++++ .../javascripts/discourse/templates/full-page-search.hbs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/search-menu.js.es6 b/app/assets/javascripts/discourse/components/search-menu.js.es6 index 153929ecd6b..41352528076 100644 --- a/app/assets/javascripts/discourse/components/search-menu.js.es6 +++ b/app/assets/javascripts/discourse/components/search-menu.js.es6 @@ -134,7 +134,7 @@ export default Ember.Component.extend({ }, showedSearch() { - $('#search-term').focus(); + $('#search-term').focus().select(); }, showSearchHelp() { diff --git a/app/assets/javascripts/discourse/components/search-text-field.js.es6 b/app/assets/javascripts/discourse/components/search-text-field.js.es6 index bf46ddf33f3..bb83304bcb2 100644 --- a/app/assets/javascripts/discourse/components/search-text-field.js.es6 +++ b/app/assets/javascripts/discourse/components/search-text-field.js.es6 @@ -5,5 +5,9 @@ export default TextField.extend({ @computed('searchService.searchContextEnabled') placeholder: function(searchContextEnabled) { return searchContextEnabled ? "" : I18n.t('search.title'); + }, + + focusIn: function() { + Em.run.later(() => { this.$().select(); }); } }); diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index 43e3e835ad5..3b9bebb9620 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -1,5 +1,5 @@