Bläddra i källkod

fix: Focus lost after modifying filter or search params (#696)

Signed-off-by: ryjiang <jiangruiyi@gmail.com>
ryjiang 5 månader sedan
förälder
incheckning
a6511e3c17

+ 2 - 14
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

+ 0 - 1
client/src/pages/search/SearchParams.tsx

@@ -216,7 +216,6 @@ const SearchParams: FC<SearchParamsProps> = ({
           isInt: false,
           required: false,
           handleChange: value => {
-            console.log(value, typeof value);
             handleInputChange('radius', value);
           },
           className: classes.inlineInput,