From 2beeafd5deb57ce4db7a93d07abdff6cd391136a Mon Sep 17 00:00:00 2001 From: xdm <35987327+xiaodemen@users.noreply.github.com> Date: Fri, 16 Oct 2026 13:07:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9Adragging=20a=20request=20to=20anoth?= =?UTF-8?q?er=20collection=20within=20same=20project=20is=20allowed=20(#10?= =?UTF-8?q?612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../use-sidebar-drag-and-drop.tsx | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/use-sidebar-drag-and-drop.tsx b/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/use-sidebar-drag-and-drop.tsx index c3853f6ba5..4de05d8b12 100644 --- a/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/use-sidebar-drag-and-drop.tsx +++ b/packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/use-sidebar-drag-and-drop.tsx @@ -99,9 +99,12 @@ function indentRemForLevel(level: number, depthOffset: number): number { // Deeper and shallower side of a multi-depth gap, or null for a same-level // insert. Both raw forms of one gap map to the same pair. -function resolveGapSides( - { dropPosition, targetItem, realTargetItem, nextItem }: BoundaryTargets, -): { deep: CollectionChildFlatItem; shallow: CollectionChildFlatItem } | null { +function resolveGapSides({ + dropPosition, + targetItem, + realTargetItem, + nextItem, +}: BoundaryTargets): { deep: CollectionChildFlatItem; shallow: CollectionChildFlatItem } | null { const otherItem = dropPosition === 'before' ? realTargetItem : nextItem; if (!isCollectionChild(targetItem) || !isCollectionChild(otherItem)) { return null; @@ -115,9 +118,7 @@ function resolveGapSides( if (dropPosition === 'after' && targetLevel < otherLevel) { return null; } - return targetLevel > otherLevel - ? { deep: targetItem, shallow: otherItem } - : { deep: otherItem, shallow: targetItem }; + return targetLevel > otherLevel ? { deep: targetItem, shallow: otherItem } : { deep: otherItem, shallow: targetItem }; } // react-stately treats `after X` and `before nextKey(X)` as one insertion point @@ -381,10 +382,10 @@ export function canDrop( return false; } - // move request and request group into collection + // move request and request group into collection/design if ( realDropItem.kind === 'workspace' && - models.workspace.isCollection(realDropItem.doc) && + (models.workspace.isCollection(realDropItem.doc) || models.workspace.isDesign(realDropItem.doc)) && // collection is same with design (models.requestGroup.isRequestGroup(dragItem.doc) || models.request.isRequest(dragItem.doc)) ) { // Repositioning inside its own collection is not a cross-collection move, so @@ -392,6 +393,10 @@ export function canDrop( if (isCollectionChild(dragItem) && dragItem.workspace._id === realDropItem.doc._id) { return true; } + // allow if they are both part of the same project + if (dragItem.project._id === realDropItem.project._id) { + return true; + } // Moving BETWEEN collections cannot involve cloud sync on either side. const dropInCloud = models.project.isRemoteProject(realDropItem.project); return !dragInCloud && !dropInCloud; @@ -806,7 +811,10 @@ export const useSidebarDragAndDrop = ({ targetId: realTargetItem!.doc._id, id: draggedItem.doc._id, dropPosition: 'after', // collection only accepts move into, so treat all drops as "after" - metaSortKey: firstChildOfCollection?.doc.metaSortKey != null ? firstChildOfCollection.doc.metaSortKey - 100 : -1 * Date.now(), + metaSortKey: + firstChildOfCollection?.doc.metaSortKey != null + ? firstChildOfCollection.doc.metaSortKey - 100 + : -1 * Date.now(), }, }); return;