Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions packages/ui/src/providers/Folders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,27 +320,41 @@ export function FolderProvider({
}, [selectedItemKeys, getItem])

const navigateAfterSelection = React.useCallback(
({ collectionSlug, docID }: { collectionSlug: string; docID?: number | string }) => {
({
collectionSlug,
docID,
openInNewTab = false,
}: {
collectionSlug: string
docID?: number | string
openInNewTab?: boolean
}) => {
if (drawerDepth === 1) {
// not in a drawer (default is 1)
let targetURL: string | undefined

if (collectionSlug === folderCollectionSlug) {
// clicked on folder, take the user to the folder view
startRouteTransition(() => {
router.push(getFolderRoute(docID))
clearSelections()
})
targetURL = getFolderRoute(docID)
} else if (collectionSlug) {
// clicked on document, take the user to the documet view
startRouteTransition(() => {
router.push(
formatAdminURL({
adminRoute: config.routes.admin,
path: `/collections/${collectionSlug}/${docID}`,
}),
)
clearSelections()
// clicked on document, take the user to the document view
targetURL = formatAdminURL({
adminRoute: config.routes.admin,
path: `/collections/${collectionSlug}/${docID}`,
})
}

if (targetURL) {
if (openInNewTab) {
window.open(targetURL, '_blank', 'noopener,noreferrer')
clearSelections()
} else {
startRouteTransition(() => {
router.push(targetURL)
clearSelections()
})
}
}
} else {
clearSelections()
}
Expand Down Expand Up @@ -591,6 +605,16 @@ export function FolderProvider({
const allItems = [...subfolders, ...documents]
const currentItemIndex = allItems.findIndex((item) => item.itemKey === clickedItem.itemKey)

if ((isCtrlPressed || isShiftPressed) && event.type !== 'pointermove') {
event.preventDefault()
navigateAfterSelection({
collectionSlug: clickedItem.relationTo,
docID: extractID(clickedItem.value),
openInNewTab: true,
})
return
}

if (allowMultiSelection && isCtrlPressed) {
event.preventDefault()
let overlayItemKey: FolderDocumentItemKey | undefined
Expand Down
Loading