Skip to content

Commit

Permalink
Display "No results" message when no search results found
Browse files Browse the repository at this point in the history
no issue
- add a "No results" element to the search dropdown on creation and show/hide it appropriately
  • Loading branch information
kevinansfield committed Sep 2, 2015
1 parent 3002c1b commit 580eaf0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions core/client/app/components/gh-search-input.js
Expand Up @@ -117,13 +117,36 @@ export default Ember.Component.extend({
this.get('_selectize').focus();
},

onInit: function () {
var selectize = this.get('_selectize'),
html = '<div class="dropdown-empty-message">No results...</div>';

selectize.$empty_results_container = $(html);
selectize.$empty_results_container.hide();
selectize.$dropdown.append(selectize.$empty_results_container);
},

onFocus: function () {
this._setKeymasterScope();
this.refreshContent();
},

onBlur: function () {
var selectize = this.get('_selectize');

this._resetKeymasterScope();
selectize.$empty_results_container.hide();
},

onType: function () {
var selectize = this.get('_selectize');

if (!selectize.hasOptions) {
selectize.open();
selectize.$empty_results_container.show();
} else {
selectize.$empty_results_container.hide();
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/client/app/styles/components/selectize.css
Expand Up @@ -209,7 +209,8 @@
border-radius: 1px;
}
.selectize-dropdown [data-selectable],
.selectize-dropdown .optgroup-header {
.selectize-dropdown .optgroup-header,
.selectize-dropdown .dropdown-empty-message {
padding: 5px 8px;
}
.selectize-dropdown .optgroup:first-child .optgroup-header {
Expand Down
2 changes: 2 additions & 0 deletions core/client/app/templates/components/gh-search-input.hbs
Expand Up @@ -8,7 +8,9 @@
optionGroupPath="content.category"
openOnFocus=false
maxItems="1"
on-init="onInit"
on-focus="onFocus"
on-blur="onBlur"
update-filter="onType"
select-item="openSelected"}}
<button class="gh-nav-search-button" {{action "focusInput"}}><i class="icon-search"></i><span class="sr-only">Search</span></button>

0 comments on commit 580eaf0

Please sign in to comment.