From d54c323ff2bef9044ef0f7452136c620b0a1e2fd Mon Sep 17 00:00:00 2001 From: cyan <504512494@qq.com> Date: Mon, 1 Apr 2024 17:47:08 +0800 Subject: [PATCH] fix: the search query is not synchronized with the input value (#297) --- src/components/IconSet.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/IconSet.vue b/src/components/IconSet.vue index 6531d4fe..a0b926c6 100755 --- a/src/components/IconSet.vue +++ b/src/components/IconSet.vue @@ -104,12 +104,19 @@ watch( onMounted(() => { search.value = route.query.s as string || '' - watch([search, collection], () => { + watch([search], () => { + synchronizeSearchQuery() + }) + watch([collection], () => { if (search.value) - router.replace({ query: { s: search.value } }) + synchronizeSearchQuery() }) }) +function synchronizeSearchQuery() { + router.replace({ query: { s: search.value } }) +} + function focusSearch() { searchbar.value?.input.focus() }