From 2dea65f24be95739ade28c86d234c4131e31ee9c Mon Sep 17 00:00:00 2001 From: fadilsid Date: Tue, 27 Aug 2024 21:47:38 +0000 Subject: [PATCH 1/2] fix: Autocomplete search in Link component (cherry picked from commit 6d7078db2c7ba2df41e37d2c7f6994c099d774cf) --- frontend/src/components/Link.vue | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Link.vue b/frontend/src/components/Link.vue index cb05cfeacb..d98d4b0737 100644 --- a/frontend/src/components/Link.vue +++ b/frontend/src/components/Link.vue @@ -7,6 +7,7 @@ :options="options.data" :class="disabled ? 'pointer-events-none' : ''" :disabled="disabled" + @update:query="handleQueryUpdate" /> @@ -84,14 +85,10 @@ watch( { immediate: true } ) -watch( - () => autocompleteRef.value?.query, - (val) => { - val = val || "" - if (searchText.value === val) return - searchText.value = val - reloadOptions(val) - }, - { immediate: true } -) +const handleQueryUpdate = (newQuery) => { + const val = newQuery || "" + if (searchText.value === val) return + searchText.value = val + reloadOptions(val) +} \ No newline at end of file From 6bef962b2d4d521f4b59f5a1bbb1578d9c1eddcd Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 28 Aug 2024 12:18:09 +0530 Subject: [PATCH 2/2] fix: move debounce to query update + fix formatting (cherry picked from commit f336e70a2ee8c9aca91b088f836cf0f6f1135773) --- frontend/src/components/Link.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Link.vue b/frontend/src/components/Link.vue index d98d4b0737..0f661b94de 100644 --- a/frontend/src/components/Link.vue +++ b/frontend/src/components/Link.vue @@ -66,7 +66,7 @@ const options = createResource({ }, }) -const reloadOptions = debounce((searchTextVal) => { +const reloadOptions = (searchTextVal) => { options.update({ params: { txt: searchTextVal, @@ -74,6 +74,13 @@ const reloadOptions = debounce((searchTextVal) => { }, }) options.reload() +} + +const handleQueryUpdate = debounce((newQuery) => { + const val = newQuery || "" + if (searchText.value === val) return + searchText.val = val + reloadOptions(val) }, 300) watch( @@ -84,11 +91,4 @@ watch( }, { immediate: true } ) - -const handleQueryUpdate = (newQuery) => { - const val = newQuery || "" - if (searchText.value === val) return - searchText.value = val - reloadOptions(val) -} \ No newline at end of file