UBER-76: trigger search after timeout (#3193)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2023-05-17 11:11:56 +05:00 committed by GitHub
parent 4949142b19
commit d816b99e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,15 @@
$: _search = value
const dispatch = createEventDispatcher()
let timer: any
function restartTimer () {
clearTimeout(timer)
timer = setTimeout(() => {
value = _search
dispatch('change', _search)
}, 500)
}
</script>
<EditWithIcon
@ -22,6 +31,7 @@
}
}}
on:input={() => {
restartTimer()
if (_search === '') {
value = ''
dispatch('change', '')