Skip to content

Commit

Permalink
UX: when on full page search header search should not pop open
Browse files Browse the repository at this point in the history
fix `/` handling in full page search to highlight search term
  • Loading branch information
SamSaffron committed Sep 18, 2015
1 parent 7067d32 commit 086d31d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
Expand Up @@ -22,7 +22,11 @@ export default Ember.Component.extend({
if (this.siteSettings.login_required && !this.currentUser) {
this.sendAction('loginAction');
} else {
this.toggleProperty('toggleVisible');
if (this.get('action')) {
this.sendAction('action');
} else {
this.toggleProperty('toggleVisible');
}
}
this.appEvents.trigger('dropdowns:closeAll');
}
Expand Down
9 changes: 9 additions & 0 deletions app/assets/javascripts/discourse/controllers/header.js.es6
Expand Up @@ -20,6 +20,15 @@ const HeaderController = Ember.Controller.extend({


actions: {
toggleSearch() {
// there may be a cleaner way, but this is so trivial code wise
const $fullpageSearch = $('input.full-page-search');
if ($fullpageSearch.length === 1) {
$fullpageSearch.focus().select();
} else {
this.toggleProperty('searchVisible');
}
},
showUserMenu() {
if (!this.get('userMenuVisible')) {
this.appEvents.trigger('dropdowns:closeAll');
Expand Down
Expand Up @@ -177,7 +177,8 @@ export default {
},

showSearch() {
this.container.lookup('controller:header').send('toggleMenuPanel', 'searchVisible');
this.container.lookup('controller:header').send('toggleSearch');
return false;
},

toggleHamburgerMenu() {
Expand Down
@@ -1,5 +1,5 @@
<div class="search row clearfix">
{{search-text-field value=searchTerm class="input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
{{search-text-field value=searchTerm class="full-page-search input-xxlarge search no-blur" action="search" hasAutofocus=hasAutofocus}}
{{d-button action="search" icon="search" class="btn-primary" disabled=searchButtonDisabled}}
{{#if canBulkSelect}}
{{#if model.posts}}
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/discourse/templates/header.hbs
Expand Up @@ -17,6 +17,7 @@

{{#header-dropdown iconId="search-button"
icon="search"
action="toggleSearch"
toggleVisible=searchVisible
mobileAction="fullPageSearch"
loginAction="showLogin"
Expand Down

0 comments on commit 086d31d

Please sign in to comment.