fix: dnd box z-index (#1353)
Some checks are pending
Alpha Build / alpha (macos-latest, aarch64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (macos-latest, x86_64-apple-darwin) (push) Waiting to run
Alpha Build / alpha (windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha (windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, aarch64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, armv7-unknown-linux-gnueabihf) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, i686-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-linux (ubuntu-latest, x86_64-unknown-linux-gnu) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (arm64, windows-latest, aarch64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x64, windows-latest, x86_64-pc-windows-msvc) (push) Waiting to run
Alpha Build / alpha-for-fixed-webview2 (x86, windows-latest, i686-pc-windows-msvc) (push) Waiting to run
Alpha Build / Update tag (push) Blocked by required conditions

* fix: dnd box z-index

* fix: dnd boxes
This commit is contained in:
Akioe Yu 2024-07-08 10:49:57 +08:00 committed by GitHub
parent 1dcc95d16a
commit 9d045e24db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 53 additions and 7 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -32,8 +32,14 @@ let eventListener: UnlistenFn | null = null;
export const TestItem = (props: 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 [anchorEl, setAnchorEl] = useState<any>(null);
@ -99,8 +105,10 @@ export const TestItem = (props: Props) => {
return (
<Box
sx={{
position: "relative",
transform: CSS.Transform.toString(transform),
transition,
zIndex: isDragging ? "calc(infinity)" : undefined,
}}
>
<TestBox