From 02ee7fd9733a8f1f9f558fa1eeff1f167c9658e0 Mon Sep 17 00:00:00 2001 From: ryjiang Date: Fri, 15 Nov 2024 19:33:20 +0800 Subject: [PATCH] fix: Focus lost after modifying filter or search params Signed-off-by: ryjiang --- .../collections/search/VectorInputBox.tsx | 16 ++-------------- client/src/pages/search/SearchParams.tsx | 1 - 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/client/src/pages/databases/collections/search/VectorInputBox.tsx b/client/src/pages/databases/collections/search/VectorInputBox.tsx index 89ac7974..b2e0a64c 100644 --- a/client/src/pages/databases/collections/search/VectorInputBox.tsx +++ b/client/src/pages/databases/collections/search/VectorInputBox.tsx @@ -143,19 +143,6 @@ export default function VectorInputBox(props: VectorInputBoxProps) { onChangeRef.current = onChange; fieldRef.current = field; searchParamsRef.current = searchParams; - - if (editor.current) { - // only data replace should trigger this, otherwise, let cm handle the state - if (editor.current.state.doc.toString() !== data) { - editor.current.dispatch({ - changes: { - from: 0, - to: data.length + 1, - insert: data, - }, - }); - } - } }, [JSON.stringify(searchParams), onChange]); const getVectorById = (text: string) => { @@ -293,6 +280,7 @@ export default function VectorInputBox(props: VectorInputBoxProps) { editor.current.dispatch({ selection: { anchor: endPos }, }); + editor.current.focus(); return () => { @@ -300,7 +288,7 @@ export default function VectorInputBox(props: VectorInputBoxProps) { editor.current = undefined; }; } - }, [JSON.stringify(field), getVectorById]); + }, [JSON.stringify({ field, data })]); useEffect(() => { // dispatch dark mode change to editor diff --git a/client/src/pages/search/SearchParams.tsx b/client/src/pages/search/SearchParams.tsx index b3822bf7..47974ebc 100644 --- a/client/src/pages/search/SearchParams.tsx +++ b/client/src/pages/search/SearchParams.tsx @@ -216,7 +216,6 @@ const SearchParams: FC = ({ isInt: false, required: false, handleChange: value => { - console.log(value, typeof value); handleInputChange('radius', value); }, className: classes.inlineInput,