Skip to content

Commit 4a18178

Browse files
committed
proper search debounce
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent fb2aa9c commit 4a18178

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

ui/src/components/widgets/InfiniteScrollSelect.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
:loading="loading"
6060
show-search
6161
placeholder="Select"
62-
@search="onSearch"
62+
@search="onSearchTimed"
6363
@popupScroll="onScroll"
6464
@change="onChange"
6565
>
@@ -144,6 +144,7 @@ export default {
144144
totalCount: null,
145145
loading: false,
146146
searchQuery: '',
147+
searchTimer: null,
147148
scrollHandlerAttached: false,
148149
preselectedOptionValue: null,
149150
successiveFetches: 0
@@ -238,10 +239,13 @@ export default {
238239
this.preselectedOptionValue = null
239240
this.successiveFetches = 0
240241
},
242+
onSearchTimed (value) {
243+
clearTimeout(this.searchTimer)
244+
this.searchTimer = setTimeout(() => {
245+
this.onSearch(value)
246+
}, 500)
247+
},
241248
onSearch (value) {
242-
if (value && value.length > 0 && value.length < 3) {
243-
return
244-
}
245249
this.searchQuery = value
246250
this.page = 1
247251
this.totalCount = null

0 commit comments

Comments
 (0)