Skip to content

Commit 07957f7

Browse files
committed
add search as you type
1 parent 3b48354 commit 07957f7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

webui/src/components/dashboard/Search.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import router from '@/router';
3-
import { computed, onMounted, ref } from 'vue';
3+
import { computed, onMounted, ref, watch } from 'vue';
44
import { useRoute } from 'vue-router';
55
66
const route = useRoute()
@@ -33,6 +33,13 @@ const pageRange = computed(() => {
3333
3434
return Array.from({ length: end - start + 1 }, (_, i) => start + i)
3535
})
36+
let timeout: number;
37+
watch(queryText, async (q) => {
38+
// debounced
39+
clearTimeout(timeout)
40+
timeout = setTimeout(async () => {await search()}, 300)
41+
})
42+
3643
function navigateToSearchResult(result: any) {
3744
switch (result.type.toLowerCase()) {
3845
case 'http':

0 commit comments

Comments
 (0)