Skip to content

Commit b7b5a5c

Browse files
Merge pull request #425 from victorneuret/master
Add option to display suggestion on setInput
2 parents 2a87687 + 3b792b6 commit b7b5a5c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

API.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ Set input
186186
#### Parameters
187187

188188
* `searchInput` **[string][76]** location name or other search input
189+
- `showSuggestions` **[boolean][80]** display suggestion on setInput call (optional, default `false`)
189190

190191
Returns **[MapboxGeocoder][2]** this
191192

lib/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,15 +928,20 @@ MapboxGeocoder.prototype = {
928928
/**
929929
* Set input
930930
* @param {string} searchInput location name or other search input
931+
* @param {boolean} [showSuggestions=false] display suggestion on setInput call
931932
* @returns {MapboxGeocoder} this
932933
*/
933-
setInput: function(searchInput) {
934+
setInput: function(searchInput, showSuggestions) {
935+
if (showSuggestions === undefined) {
936+
showSuggestions = false
937+
}
934938
// Set input value to passed value and clear everything else.
935939
this._inputEl.value = searchInput;
936940
this._typeahead.selected = null;
937941
this._typeahead.clear();
938942
if (searchInput.length >= this.options.minLength) {
939-
this._geocode(searchInput);
943+
showSuggestions ? this._geocode(searchInput) : this._onChange();
944+
}
940945
}
941946
return this;
942947
},

0 commit comments

Comments
 (0)