From 42b91b6294767144aca04e42ca2fdd87a04f7271 Mon Sep 17 00:00:00 2001 From: oomeow Date: Tue, 18 Aug 2026 15:38:31 +0000 Subject: [PATCH] fix: add input ref and focus search fields on toggle (#7766) * fix: add input ref and focus search fields on toggle * refactor(proxy): remove unnecessary delay in input focus timeouts --- src/components/base/base-search-box.tsx | 3 +++ src/components/proxy/proxy-group-tools.tsx | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/base/base-search-box.tsx b/src/components/base/base-search-box.tsx index 0eecc792b..9f12fc997 100644 --- a/src/components/base/base-search-box.tsx +++ b/src/components/base/base-search-box.tsx @@ -27,6 +27,7 @@ export type SearchState = { type SearchOptionState = Omit type SearchProps = { + inputRef?: React.RefObject value?: string defaultValue?: string autoFocus?: boolean @@ -73,6 +74,7 @@ const useControllableState = (options: { } export const BaseSearchBox = ({ + inputRef, value, defaultValue, autoFocus, @@ -200,6 +202,7 @@ export const BaseSearchBox = ({ return ( (null) + useEffect(() => { delayManager.setUrl(groupName, testUrl?.trim() || url || defaultLatencyUrl) }, [groupName, testUrl, defaultLatencyUrl, url]) @@ -102,7 +104,7 @@ export const ProxyGroupTools = memo(function ProxyGroupTools(props: Props) { {textState === 'filter' && ( inputRef.current?.focus()) }} > {textState === 'url' ? ( @@ -249,6 +253,7 @@ export const ProxyGroupTools = memo(function ProxyGroupTools(props: Props) { // eslint-disable-next-line @eslint-react/dom-no-flush-sync flushSync(() => onHeadState({ open: true })) onHeadState({ textState: textState === 'filter' ? null : 'filter' }) + setTimeout(() => inputRef.current?.focus()) }} > {textState === 'filter' ? (