diff --git a/app/assets/javascripts/discourse/widgets/header.js.es6 b/app/assets/javascripts/discourse/widgets/header.js.es6 index b4974104bb9..a61f26d5c49 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() {