mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-04-18 16:30:32 +08:00
fix: prevent drag listeners from blocking navigation clicks in sidebar #5567
Separated dnd-kit drag handlers (attributes/listeners) from ListItemButton
to ListItemIcon only. Previously, long-press or rapid clicks on nav items
would trigger drag detection and cancel the click event, causing the item
to visually highlight but fail to navigate.
Changes:
- Moved sortable attributes/listeners to icon elements only
- ListItemButton now handles pure navigation clicks without interference
- Drag handle cursor ('grab') remains on icons when sortable is enabled
Fixes issue where sidebar tabs would "go dark" without actual route change.
This commit is contained in:
parent
cbab199f80
commit
ddd24eb3ac
@ -6,11 +6,11 @@ import {
|
|||||||
alpha,
|
alpha,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemButton,
|
ListItemButton,
|
||||||
ListItemText,
|
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
|
ListItemText,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import type { CSSProperties, ReactNode } from "react";
|
import type { CSSProperties, ReactNode } from "react";
|
||||||
import { useMatch, useResolvedPath, useNavigate } from "react-router";
|
import { useMatch, useNavigate, useResolvedPath } from "react-router";
|
||||||
|
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export const LayoutItem = (props: Props) => {
|
|||||||
paddingLeft: 1,
|
paddingLeft: 1,
|
||||||
paddingRight: 1,
|
paddingRight: 1,
|
||||||
marginRight: 1.25,
|
marginRight: 1.25,
|
||||||
cursor: sortable && !sortable.disabled ? "grab" : "pointer",
|
cursor: "pointer",
|
||||||
"& .MuiListItemText-primary": {
|
"& .MuiListItemText-primary": {
|
||||||
color: "text.primary",
|
color: "text.primary",
|
||||||
fontWeight: "700",
|
fontWeight: "700",
|
||||||
@ -70,7 +70,6 @@ export const LayoutItem = (props: Props) => {
|
|||||||
? alpha(primary.main, 0.15)
|
? alpha(primary.main, 0.15)
|
||||||
: alpha(primary.main, 0.35);
|
: alpha(primary.main, 0.35);
|
||||||
const color = mode === "light" ? "#1f1f1f" : "#ffffff";
|
const color = mode === "light" ? "#1f1f1f" : "#ffffff";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"&.Mui-selected": { bgcolor },
|
"&.Mui-selected": { bgcolor },
|
||||||
"&.Mui-selected:hover": { bgcolor },
|
"&.Mui-selected:hover": { bgcolor },
|
||||||
@ -79,15 +78,29 @@ export const LayoutItem = (props: Props) => {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
onClick={() => navigate(to)}
|
onClick={() => navigate(to)}
|
||||||
{...(attributes ?? {})}
|
|
||||||
{...(listeners ?? {})}
|
|
||||||
>
|
>
|
||||||
{(menu_icon === "monochrome" || !menu_icon) && (
|
{(menu_icon === "monochrome" || !menu_icon) && (
|
||||||
<ListItemIcon sx={{ color: "text.primary", marginLeft: "6px" }}>
|
<ListItemIcon
|
||||||
|
sx={{
|
||||||
|
color: "text.primary",
|
||||||
|
marginLeft: "6px",
|
||||||
|
cursor: sortable && !sortable.disabled ? "grab" : "inherit",
|
||||||
|
}}
|
||||||
|
{...(attributes ?? {})}
|
||||||
|
{...(listeners ?? {})}
|
||||||
|
>
|
||||||
{icon[0]}
|
{icon[0]}
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
)}
|
)}
|
||||||
{menu_icon === "colorful" && <ListItemIcon>{icon[1]}</ListItemIcon>}
|
{menu_icon === "colorful" && (
|
||||||
|
<ListItemIcon
|
||||||
|
sx={{ cursor: sortable && !sortable.disabled ? "grab" : "inherit" }}
|
||||||
|
{...(attributes ?? {})}
|
||||||
|
{...(listeners ?? {})}
|
||||||
|
>
|
||||||
|
{icon[1]}
|
||||||
|
</ListItemIcon>
|
||||||
|
)}
|
||||||
<ListItemText
|
<ListItemText
|
||||||
sx={{
|
sx={{
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user