From e619af3eeeb73fe7a28505c39d5c20eb8d86c3db Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 8 Jul 2016 14:17:02 +0800 Subject: [PATCH] UX: Select text in input when toggling search menu. --- app/assets/javascripts/discourse/widgets/header.js.es6 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6 index b4974104b..a61f26d5c 100644 --- a/app/assets/javascripts/discourse/widgets/header.js.es6 +++ b/app/assets/javascripts/discourse/widgets/header.js.es6 @@ -215,7 +215,10 @@ export default createWidget('header', { this.state.searchVisible = !this.state.searchVisible; this.updateHighlight(); - Ember.run.next(() => $('#search-term').focus()); + + if (this.state.searchVisible) { + Ember.run.schedule('afterRender', () => $('#search-term').focus().select()); + } }, toggleUserMenu() {