fix: pasting request ito parent folder even if request is selected (#6446)

This commit is contained in:
Pooja
2025-12-24 12:14:37 +05:30
committed by GitHub
parent c2acc25461
commit 1f05ffd469
2 changed files with 23 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ import ExampleIcon from 'components/Icons/ExampleIcon';
import { scrollToTheActiveTab } from 'utils/tabs';
import { isTabForItemActive as isTabForItemActiveSelector, isTabForItemPresent as isTabForItemPresentSelector } from 'src/selectors/tab';
import { isEqual } from 'lodash';
import { calculateDraggedItemNewPathname, getInitialExampleName } from 'utils/collections/index';
import { calculateDraggedItemNewPathname, getInitialExampleName, findParentItemInCollection } from 'utils/collections/index';
import { sortByNameThenSequence } from 'utils/common/index';
import CreateExampleModal from 'components/ResponseExample/CreateExampleModal';
import { openDevtoolsAndSwitchToTerminal } from 'utils/terminal';
@@ -533,13 +533,14 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText })
};
const handlePasteItem = () => {
// Only allow paste into folders
// Determine target folder: if item is a folder, paste into it; otherwise paste into parent folder
let targetFolderUid = item.uid;
if (!isFolder) {
toast.error('Paste is only available for folders');
return;
const parentFolder = findParentItemInCollection(collection, item.uid);
targetFolderUid = parentFolder ? parentFolder.uid : null;
}
dispatch(pasteItem(collectionUid, item.uid))
dispatch(pasteItem(collectionUid, targetFolderUid))
.then(() => {
toast.success('Item pasted successfully');
})