diff --git a/src/components/search/SearchFilter.vue b/src/components/search/SearchFilter.vue index 0323e422fb97bc66cb6208688f28a7e1d8140c41..1c675b3119fa60f4d770791ae6059b283471c597 100644 --- a/src/components/search/SearchFilter.vue +++ b/src/components/search/SearchFilter.vue @@ -108,22 +108,17 @@ const clickRecommend = (v: string) => { }; const isFocus = ref(false); +let focusInput: string | null; const changeSearchFocus = (state: boolean) => { isFocus.value = state; + focusInput = searchInput.value; reportAnalytics({ type: 'search_input', }); }; const changeSearchBlur = () => { - const name = route.query.name as string; - if (isPageSearch.value) { - if (searchInput.value === '' || name !== searchInput.value) { - searchInput.value = name; - } - return; - } - if (searchInput.value) { + if (searchInput.value && focusInput !== searchInput.value) { reportAnalytics( { content: searchInput.value, @@ -131,6 +126,13 @@ const changeSearchBlur = () => { 'input' ); } + focusInput = null; + const name = route.query.name as string; + if (isPageSearch.value) { + if (searchInput.value === '' || name !== searchInput.value) { + searchInput.value = name; + } + } }; onClickOutside(searchRef, () => {