From ca49cd7a80f40043d4bc39d55e1aae43d8e09d5f Mon Sep 17 00:00:00 2001 From: sendevia Date: Sun, 30 Nov 2025 21:54:51 +0800 Subject: [PATCH] feat(search): conditionally activate search on focus --- .vitepress/theme/stores/searchState.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.vitepress/theme/stores/searchState.ts b/.vitepress/theme/stores/searchState.ts index af188bf..05b949b 100644 --- a/.vitepress/theme/stores/searchState.ts +++ b/.vitepress/theme/stores/searchState.ts @@ -57,9 +57,11 @@ export const useSearchStateStore = defineStore("searchState", () => { } } - // 监听状态变化 - watch(isSearchFocused, () => { - isSearchActive.value = true; + // 监听 isSearchFocused 变化,当获得焦点时,自动激活搜索 + watch(isSearchFocused, (focused) => { + if (focused && !isSearchActive.value) { + isSearchActive.value = true; + } }); return {