Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"release": "npm publish; git add . -A; git commit; git push --tags"
},
"dependencies": {
"debounce": "^1.2.0",
"vue": "^2.6.11",
"vue-interface": "^0.4.52"
},
Expand Down
23 changes: 14 additions & 9 deletions src/PlaceAutocompleteField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import FormControl from 'vue-interface/src/Mixins/FormControl';
import FormGroup from 'vue-interface/src/Components/FormGroup';
import InputField from 'vue-interface/src/Components/InputField';
import ActivityIndicator from 'vue-interface/src/Components/ActivityIndicator';
import debounce from "debounce";

const KEYCODE = {
ESC: 27,
Expand Down Expand Up @@ -114,7 +115,7 @@ export default {
types: {
type: [Boolean, Array],
default: false
}
},

},

Expand Down Expand Up @@ -146,6 +147,17 @@ export default {
});
},

searchDebounce: debounce(function() {
this.search().then(response => {
this.predictions = response;
this.showPredictions = true;
}, error => {
if (error) {
this.predictions = false;
}
});
}, 200),

search() {
return new Promise((resolve, reject) => {
if (!this.getInputElement().value) {
Expand Down Expand Up @@ -232,14 +244,7 @@ export default {
return;
}

this.search().then(response => {
this.predictions = response;
this.showPredictions = true;
}, error => {
if (error) {
this.predictions = false;
}
});
this.searchDebounce();
},

onFocus(event) {
Expand Down