fix: auto scroll into view when sorted proxies changed

This commit is contained in:
GyDi 2022-10-26 01:24:06 +08:00
parent a6ac75e97b
commit 59dae640db
No known key found for this signature in database
GPG Key ID: 58B15242BA8277A6

View File

@ -111,9 +111,18 @@ const ProxyGroup = ({ group }: Props) => {
// auto scroll to current index // auto scroll to current index
useEffect(() => { useEffect(() => {
if (headState.open) { 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 ( return (
<> <>