Skip to content

Commit

Permalink
Check if the input is empty before sorting and filterin options
Browse files Browse the repository at this point in the history
  • Loading branch information
benguozakinci@gmail.com authored and benguozakinci@gmail.com committed Jul 27, 2021
1 parent d363b11 commit a28dd08
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions resources/assets/js/components/AkauntingItemButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default {
return {
item_list: [],
selected_items: [],
search: '', // search coLumn model
search: '', // search column model
show: {
item_selected: false,
item_list: false,
Expand Down Expand Up @@ -269,13 +269,18 @@ export default {
},
onInput() {
if (this.search.length < this.searchCharLimit) {
this.setItemList(this.items);
this.sortItems();
this.$emit('input', this.search);
//to optimize performance we kept the condition that checks for if search exists or not
if (!this.search) {
return;
}
//condition that checks if input is below the given character limit
if (this.search.length < this.searchCharLimit) {
this.setItemList(this.items); //once the user deletes the search input, we show the overall item list
this.sortItems(); // we order it as wanted
this.$emit('input', this.search); // keep the input binded to v-model
return;
}
window.axios.get(url + '/common/items?search="' + this.search + '" limit:10')
.then(response => {
Expand Down

0 comments on commit a28dd08

Please sign in to comment.