Explorar el Código

fix: auto scroll into view when sorted proxies changed

GyDi hace 2 años
padre
commit
59dae640db
Se han modificado 1 ficheros con 11 adiciones y 2 borrados
  1. 11 2
      src/components/proxy/proxy-group.tsx

+ 11 - 2
src/components/proxy/proxy-group.tsx

@@ -111,9 +111,18 @@ const ProxyGroup = ({ group }: Props) => {
   // auto scroll to current index
   useEffect(() => {
     if (headState.open) {
-      setTimeout(() => onLocation(false), 5);
+      setTimeout(() => onLocation(false), 10);
     }
-  }, [headState.open]);
+  }, [headState.open, sortedProxies]);
+
+  // auto scroll when sorted changed
+  const timerRef = useRef<any>();
+  useEffect(() => {
+    if (headState.open) {
+      clearTimeout(timerRef.current);
+      timerRef.current = setTimeout(() => onLocation(false), 500);
+    }
+  }, [headState.open, sortedProxies]);
 
   return (
     <>