mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 03:55:55 +00:00
fix(web): prevent plugin market search trigger during IME composition
This commit is contained in:
@@ -66,6 +66,7 @@ function MarketPageContent({
|
|||||||
const pageSize = 12; // 每页12个
|
const pageSize = 12; // 每页12个
|
||||||
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const searchTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
|
const scrollContainerRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const isComposingRef = useRef(false);
|
||||||
|
|
||||||
// 排序选项
|
// 排序选项
|
||||||
const sortOptions: SortOption[] = [
|
const sortOptions: SortOption[] = [
|
||||||
@@ -250,10 +251,14 @@ function MarketPageContent({
|
|||||||
clearTimeout(searchTimeoutRef.current);
|
clearTimeout(searchTimeoutRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isComposingRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 设置新的定时器
|
// 设置新的定时器
|
||||||
searchTimeoutRef.current = setTimeout(() => {
|
searchTimeoutRef.current = setTimeout(() => {
|
||||||
handleSearch(value);
|
handleSearch(value);
|
||||||
}, 300);
|
}, 500);
|
||||||
},
|
},
|
||||||
[handleSearch],
|
[handleSearch],
|
||||||
);
|
);
|
||||||
@@ -398,6 +403,13 @@ function MarketPageContent({
|
|||||||
placeholder={t('market.searchPlaceholder')}
|
placeholder={t('market.searchPlaceholder')}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => handleSearchInputChange(e.target.value)}
|
onChange={(e) => handleSearchInputChange(e.target.value)}
|
||||||
|
onCompositionStart={() => {
|
||||||
|
isComposingRef.current = true;
|
||||||
|
}}
|
||||||
|
onCompositionEnd={(e) => {
|
||||||
|
isComposingRef.current = false;
|
||||||
|
handleSearchInputChange((e.target as HTMLInputElement).value);
|
||||||
|
}}
|
||||||
onKeyPress={(e) => {
|
onKeyPress={(e) => {
|
||||||
if (e.key === 'Enter') {
|
if (e.key === 'Enter') {
|
||||||
// Immediately search, clear debounce timer
|
// Immediately search, clear debounce timer
|
||||||
|
|||||||
Reference in New Issue
Block a user