Skip to content

Commit

Permalink
Call updateSuggestions w/o query on input change (#66)
Browse files Browse the repository at this point in the history
As long as `canShowSuggestions()` is still cool with it.

This removes the assumption that the implementor doesn't want to do something with the suggestions even when there's no query. They might want to show something like instructions or helper UI, or even some pre-generated default suggestions. This is now all possible.
  • Loading branch information
josephschmitt authored Jun 27, 2017
1 parent a6615f9 commit 53db3b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngc-omnibox",
"version": "0.4.3",
"version": "0.5.0",
"description": "A modern, flexible, Angular 1.x autocomplete library with limited assumptions.",
"main": "dist/ngc-omnibox.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions spec/tests/angularComponent/ngcOmniboxControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe('ngcOmnibox.angularComponent.ngcOmniboxController', () => {
omniboxController.isSelectable = () => {};
omniboxController.onChosen = () => {};
omniboxController.onUnchosen = () => {};
omniboxController.canShowSuggestions = () => {};
omniboxController.source = () => Promise.resolve([]);
});

it('should inject $document, $element, and $scope', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/angularComponent/ngcOmniboxController.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ export default class NgcOmniboxController {
if (!this.query) {
this.hideSuggestions = true;
this.hint = null;
} else {
}

if (this.canShowSuggestions({query: this.query, omnibox: this}) !== false) {
this.updateSuggestions();
}
}
Expand Down

0 comments on commit 53db3b0

Please sign in to comment.