fix: hover jump navigator

This commit is contained in:
Slinetrac
2025-10-19 16:00:45 +08:00
parent a60cab989d
commit fbe6cefbdb
2 changed files with 26 additions and 26 deletions
+19 -1
View File
@@ -1,5 +1,5 @@
import { Box, Button, Tooltip } from "@mui/material";
import { useCallback, useMemo } from "react";
import { useCallback, useMemo, useRef } from "react";
interface ProxyGroupNavigatorProps {
proxyGroupNames: string[];
@@ -19,6 +19,8 @@ export const ProxyGroupNavigator = ({
proxyGroupNames,
onGroupLocation,
}: ProxyGroupNavigatorProps) => {
const lastHoveredRef = useRef<string | null>(null);
const handleGroupClick = useCallback(
(groupName: string) => {
onGroupLocation(groupName);
@@ -26,6 +28,19 @@ export const ProxyGroupNavigator = ({
[onGroupLocation],
);
const handleGroupHover = useCallback(
(groupName: string) => {
if (lastHoveredRef.current === groupName) return;
lastHoveredRef.current = groupName;
onGroupLocation(groupName);
},
[onGroupLocation],
);
const handleButtonLeave = useCallback(() => {
lastHoveredRef.current = null;
}, []);
// 处理代理组数据,去重和排序
const processedGroups = useMemo(() => {
return proxyGroupNames
@@ -66,6 +81,9 @@ export const ProxyGroupNavigator = ({
size="small"
variant="text"
onClick={() => handleGroupClick(name)}
onMouseEnter={() => handleGroupHover(name)}
onFocus={() => handleGroupHover(name)}
onMouseLeave={handleButtonLeave}
sx={{
minWidth: 28,
minHeight: 28,