fix: Fire query only if search term is available (#1413)
This commit is contained in:
@@ -89,18 +89,19 @@ export default {
|
|||||||
onInputSearch(event) {
|
onInputSearch(event) {
|
||||||
const newQuery = event.target.value;
|
const newQuery = event.target.value;
|
||||||
const refetchAllContacts = !!this.searchQuery && newQuery === '';
|
const refetchAllContacts = !!this.searchQuery && newQuery === '';
|
||||||
|
|
||||||
if (refetchAllContacts) {
|
if (refetchAllContacts) {
|
||||||
this.$store.dispatch('contacts/get', { page: 1 });
|
this.$store.dispatch('contacts/get', { page: 1 });
|
||||||
}
|
}
|
||||||
this.searchQuery = event.target.value;
|
this.searchQuery = newQuery;
|
||||||
},
|
},
|
||||||
onSearchSubmit() {
|
onSearchSubmit() {
|
||||||
this.selectedContactId = '';
|
this.selectedContactId = '';
|
||||||
this.$store.dispatch('contacts/search', {
|
if (this.searchQuery) {
|
||||||
search: this.searchQuery,
|
this.$store.dispatch('contacts/search', {
|
||||||
page: 1,
|
search: this.searchQuery,
|
||||||
});
|
page: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onPageChange(page) {
|
onPageChange(page) {
|
||||||
this.selectedContactId = '';
|
this.selectedContactId = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user