mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Prevent dragging folders into itself
This commit is contained in:
@@ -329,6 +329,11 @@ export function Sidebar({ className }: Props) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Block dragging folder into itself
|
||||||
|
if (hoveredTree.item.id === itemId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const parentTree = treeParentMap[itemId] ?? null;
|
const parentTree = treeParentMap[itemId] ?? null;
|
||||||
const index = parentTree?.children.findIndex((n) => n.item.id === itemId) ?? -1;
|
const index = parentTree?.children.findIndex((n) => n.item.id === itemId) ?? -1;
|
||||||
const child = parentTree?.children[index ?? -1];
|
const child = parentTree?.children[index ?? -1];
|
||||||
@@ -647,7 +652,7 @@ const SidebarItem = forwardRef(function SidebarItem(
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<li ref={ref} draggable={draggable}>
|
<li ref={ref} draggable={draggable}>
|
||||||
<div className={classNames(className, 'block relative group/item px-2 pb-0.5')}>
|
<div className={classNames(className, 'block relative group/item px-1.5 pb-0.5')}>
|
||||||
<ContextMenu
|
<ContextMenu
|
||||||
show={showContextMenu}
|
show={showContextMenu}
|
||||||
items={
|
items={
|
||||||
@@ -760,7 +765,7 @@ const SidebarItem = forwardRef(function SidebarItem(
|
|||||||
size="sm"
|
size="sm"
|
||||||
icon="chevronRight"
|
icon="chevronRight"
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'-ml-0.5 transition-transform opacity-50',
|
'transition-transform opacity-50',
|
||||||
!isCollapsed(itemId) && 'transform rotate-90',
|
!isCollapsed(itemId) && 'transform rotate-90',
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user