fix: add throttle in autocomplete

This commit is contained in:
Yohan Boniface 2024-07-02 19:06:11 +02:00
parent 2d1c4ad3c0
commit abbd0eef62

View file

@ -16,6 +16,7 @@ export class BaseAutocomplete {
allowFree: true,
minChar: 2,
maxResults: 5,
throttling: 300,
}
this.cache = ''
this.results = []
@ -125,7 +126,10 @@ export class BaseAutocomplete {
'Control',
]
if (!special.includes(e.key)) {
this.search()
if (this._typing) window.clearTimeout(this._typing)
this._typing = window.setTimeout(() => {
this.search()
}, this.options.throttling)
}
}