From cd53abc440530776fbf982801a2da63ead266fc1 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Tue, 24 Mar 2026 21:39:49 +0800 Subject: [PATCH] fix(web): prevent plugin market search trigger during IME composition --- .../plugin-market/PluginMarketComponent.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/web/src/app/home/plugins/components/plugin-market/PluginMarketComponent.tsx b/web/src/app/home/plugins/components/plugin-market/PluginMarketComponent.tsx index 46bc1e55..25d14fc6 100644 --- a/web/src/app/home/plugins/components/plugin-market/PluginMarketComponent.tsx +++ b/web/src/app/home/plugins/components/plugin-market/PluginMarketComponent.tsx @@ -66,6 +66,7 @@ function MarketPageContent({ const pageSize = 12; // 每页12个 const searchTimeoutRef = useRef(null); const scrollContainerRef = useRef(null); + const isComposingRef = useRef(false); // 排序选项 const sortOptions: SortOption[] = [ @@ -250,10 +251,14 @@ function MarketPageContent({ clearTimeout(searchTimeoutRef.current); } + if (isComposingRef.current) { + return; + } + // 设置新的定时器 searchTimeoutRef.current = setTimeout(() => { handleSearch(value); - }, 300); + }, 500); }, [handleSearch], ); @@ -398,6 +403,13 @@ function MarketPageContent({ placeholder={t('market.searchPlaceholder')} value={searchQuery} onChange={(e) => handleSearchInputChange(e.target.value)} + onCompositionStart={() => { + isComposingRef.current = true; + }} + onCompositionEnd={(e) => { + isComposingRef.current = false; + handleSearchInputChange((e.target as HTMLInputElement).value); + }} onKeyPress={(e) => { if (e.key === 'Enter') { // Immediately search, clear debounce timer