Browse Source

fix: dnd box z-index (#1353)

* fix: dnd box z-index

* fix: dnd boxes
Akioe Yu 11 months ago
parent
commit
9d045e24db

+ 11 - 1
src/components/profile/group-item.tsx

@@ -22,7 +22,14 @@ export const GroupItem = (props: Props) => {
   let { type, group, onDelete } = props;
   let { type, group, onDelete } = props;
   const sortable = type === "prepend" || type === "append";
   const sortable = type === "prepend" || type === "append";
 
 
-  const { attributes, listeners, setNodeRef, transform, transition } = sortable
+  const {
+    attributes,
+    listeners,
+    setNodeRef,
+    transform,
+    transition,
+    isDragging,
+  } = sortable
     ? useSortable({ id: group.name })
     ? useSortable({ id: group.name })
     : {
     : {
         attributes: {},
         attributes: {},
@@ -30,6 +37,7 @@ export const GroupItem = (props: Props) => {
         setNodeRef: null,
         setNodeRef: null,
         transform: null,
         transform: null,
         transition: null,
         transition: null,
+        isDragging: false,
       };
       };
 
 
   const [iconCachePath, setIconCachePath] = useState("");
   const [iconCachePath, setIconCachePath] = useState("");
@@ -55,6 +63,7 @@ export const GroupItem = (props: Props) => {
     <ListItem
     <ListItem
       dense
       dense
       sx={({ palette }) => ({
       sx={({ palette }) => ({
+        position: "relative",
         background:
         background:
           type === "original"
           type === "original"
             ? palette.mode === "dark"
             ? palette.mode === "dark"
@@ -68,6 +77,7 @@ export const GroupItem = (props: Props) => {
         borderRadius: "8px",
         borderRadius: "8px",
         transform: CSS.Transform.toString(transform),
         transform: CSS.Transform.toString(transform),
         transition,
         transition,
+        zIndex: isDragging ? "calc(infinity)" : undefined,
       })}
       })}
     >
     >
       {group.icon && group.icon?.trim().startsWith("http") && (
       {group.icon && group.icon?.trim().startsWith("http") && (

+ 10 - 2
src/components/profile/profile-item.tsx

@@ -51,8 +51,14 @@ interface Props {
 export const ProfileItem = (props: Props) => {
 export const ProfileItem = (props: Props) => {
   const { selected, activating, itemData, onSelect, onEdit, onSave, onDelete } =
   const { selected, activating, itemData, onSelect, onEdit, onSave, onDelete } =
     props;
     props;
-  const { attributes, listeners, setNodeRef, transform, transition } =
-    useSortable({ id: props.id });
+  const {
+    attributes,
+    listeners,
+    setNodeRef,
+    transform,
+    transition,
+    isDragging,
+  } = useSortable({ id: props.id });
 
 
   const { t } = useTranslation();
   const { t } = useTranslation();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -300,8 +306,10 @@ export const ProfileItem = (props: Props) => {
   return (
   return (
     <Box
     <Box
       sx={{
       sx={{
+        position: "relative",
         transform: CSS.Transform.toString(transform),
         transform: CSS.Transform.toString(transform),
         transition,
         transition,
+        zIndex: isDragging ? "calc(infinity)" : undefined,
       }}
       }}
     >
     >
       <ProfileBox
       <ProfileBox

+ 11 - 1
src/components/profile/proxy-item.tsx

@@ -20,7 +20,14 @@ export const ProxyItem = (props: Props) => {
   let { type, proxy, onDelete } = props;
   let { type, proxy, onDelete } = props;
   const sortable = type === "prepend" || type === "append";
   const sortable = type === "prepend" || type === "append";
 
 
-  const { attributes, listeners, setNodeRef, transform, transition } = sortable
+  const {
+    attributes,
+    listeners,
+    setNodeRef,
+    transform,
+    transition,
+    isDragging,
+  } = sortable
     ? useSortable({ id: proxy.name })
     ? useSortable({ id: proxy.name })
     : {
     : {
         attributes: {},
         attributes: {},
@@ -28,12 +35,14 @@ export const ProxyItem = (props: Props) => {
         setNodeRef: null,
         setNodeRef: null,
         transform: null,
         transform: null,
         transition: null,
         transition: null,
+        isDragging: false,
       };
       };
 
 
   return (
   return (
     <ListItem
     <ListItem
       dense
       dense
       sx={({ palette }) => ({
       sx={({ palette }) => ({
+        position: "relative",
         background:
         background:
           type === "original"
           type === "original"
             ? palette.mode === "dark"
             ? palette.mode === "dark"
@@ -47,6 +56,7 @@ export const ProxyItem = (props: Props) => {
         borderRadius: "8px",
         borderRadius: "8px",
         transform: CSS.Transform.toString(transform),
         transform: CSS.Transform.toString(transform),
         transition,
         transition,
+        zIndex: isDragging ? "calc(infinity)" : undefined,
       })}
       })}
     >
     >
       <ListItemText
       <ListItemText

+ 11 - 1
src/components/profile/rule-item.tsx

@@ -24,7 +24,14 @@ export const RuleItem = (props: Props) => {
   const proxyPolicy = rule.match(/[^,]+$/)?.[0] ?? "";
   const proxyPolicy = rule.match(/[^,]+$/)?.[0] ?? "";
   const ruleContent = rule.slice(ruleType.length + 1, -proxyPolicy.length - 1);
   const ruleContent = rule.slice(ruleType.length + 1, -proxyPolicy.length - 1);
 
 
-  const { attributes, listeners, setNodeRef, transform, transition } = sortable
+  const {
+    attributes,
+    listeners,
+    setNodeRef,
+    transform,
+    transition,
+    isDragging,
+  } = sortable
     ? useSortable({ id: ruleRaw })
     ? useSortable({ id: ruleRaw })
     : {
     : {
         attributes: {},
         attributes: {},
@@ -32,11 +39,13 @@ export const RuleItem = (props: Props) => {
         setNodeRef: null,
         setNodeRef: null,
         transform: null,
         transform: null,
         transition: null,
         transition: null,
+        isDragging: false,
       };
       };
   return (
   return (
     <ListItem
     <ListItem
       dense
       dense
       sx={({ palette }) => ({
       sx={({ palette }) => ({
+        position: "relative",
         background:
         background:
           type === "original"
           type === "original"
             ? palette.mode === "dark"
             ? palette.mode === "dark"
@@ -50,6 +59,7 @@ export const RuleItem = (props: Props) => {
         borderRadius: "8px",
         borderRadius: "8px",
         transform: CSS.Transform.toString(transform),
         transform: CSS.Transform.toString(transform),
         transition,
         transition,
+        zIndex: isDragging ? "calc(infinity)" : undefined,
       })}
       })}
     >
     >
       <ListItemText
       <ListItemText

+ 10 - 2
src/components/test/test-item.tsx

@@ -32,8 +32,14 @@ let eventListener: UnlistenFn | null = null;
 
 
 export const TestItem = (props: Props) => {
 export const TestItem = (props: Props) => {
   const { itemData, onEdit, onDelete: onDeleteItem } = props;
   const { itemData, onEdit, onDelete: onDeleteItem } = props;
-  const { attributes, listeners, setNodeRef, transform, transition } =
-    useSortable({ id: props.id });
+  const {
+    attributes,
+    listeners,
+    setNodeRef,
+    transform,
+    transition,
+    isDragging,
+  } = useSortable({ id: props.id });
 
 
   const { t } = useTranslation();
   const { t } = useTranslation();
   const [anchorEl, setAnchorEl] = useState<any>(null);
   const [anchorEl, setAnchorEl] = useState<any>(null);
@@ -99,8 +105,10 @@ export const TestItem = (props: Props) => {
   return (
   return (
     <Box
     <Box
       sx={{
       sx={{
+        position: "relative",
         transform: CSS.Transform.toString(transform),
         transform: CSS.Transform.toString(transform),
         transition,
         transition,
+        zIndex: isDragging ? "calc(infinity)" : undefined,
       }}
       }}
     >
     >
       <TestBox
       <TestBox