Skip to content

Commit

Permalink
Merge pull request #2128 from frappe/mergify/bp/version-15-hotfix/pr-…
Browse files Browse the repository at this point in the history
…2127

fix(PWA):  Autocomplete search functionality in Link component (backport #2127)
  • Loading branch information
ruchamahabal authored Aug 28, 2024
2 parents 3b20d28 + 6bef962 commit fe1d710
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions frontend/src/components/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:options="options.data"
:class="disabled ? 'pointer-events-none' : ''"
:disabled="disabled"
@update:query="handleQueryUpdate"
/>
</template>

Expand Down Expand Up @@ -65,14 +66,21 @@ const options = createResource({
},
})
const reloadOptions = debounce((searchTextVal) => {
const reloadOptions = (searchTextVal) => {
options.update({
params: {
txt: searchTextVal,
doctype: props.doctype,
},
})
options.reload()
}
const handleQueryUpdate = debounce((newQuery) => {
const val = newQuery || ""
if (searchText.value === val) return
searchText.val = val
reloadOptions(val)
}, 300)
watch(
Expand All @@ -83,15 +91,4 @@ watch(
},
{ immediate: true }
)
watch(
() => autocompleteRef.value?.query,
(val) => {
val = val || ""
if (searchText.value === val) return
searchText.value = val
reloadOptions(val)
},
{ immediate: true }
)
</script>

0 comments on commit fe1d710

Please sign in to comment.