Skip to content

Commit c48b57f

Browse files
authored
fix(next): incorrect doc link in trash view with groupBy enabled (#13332)
### What? Fixes an issue where document links in the trash view were incorrectly generated when group-by was enabled for a collection. Previously, links in grouped tables would omit the `/trash` segment, causing navigation to crash while trying to route to the default edit view instead of the trashed document view. ### Why? When viewing a collection in group-by mode, document rows are rendered in grouped tables via the `handleGroupBy` logic. However, these tables were unaware of whether the view was operating in trash mode, so the generated row links did not include the necessary `/trash` segment. This broke navigation when trying to view or edit trashed documents. ### How? - Threaded the `viewType` prop through `renderListView` into the `handleGroupBy` utility. - Passed `viewType` into each `renderTable` call within `handleGroupBy`, ensuring proper link generation. - `renderTable` already supports `viewType` and appends `/trash` to edit links when it's set to 'trash'.
1 parent b26a73b commit c48b57f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

packages/next/src/views/List/handleGroupBy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
PaginatedDocs,
66
PayloadRequest,
77
SanitizedCollectionConfig,
8+
ViewTypes,
89
Where,
910
} from 'payload'
1011

@@ -24,6 +25,7 @@ export const handleGroupBy = async ({
2425
req,
2526
trash = false,
2627
user,
28+
viewType,
2729
where: whereWithMergedSearch,
2830
}: {
2931
clientConfig: ClientConfig
@@ -37,6 +39,7 @@ export const handleGroupBy = async ({
3739
req: PayloadRequest
3840
trash?: boolean
3941
user: any
42+
viewType?: ViewTypes
4043
where: Where
4144
}): Promise<{
4245
columnState: Column[]
@@ -178,6 +181,7 @@ export const handleGroupBy = async ({
178181
payload: req.payload,
179182
query,
180183
useAsTitle: collectionConfig.admin.useAsTitle,
184+
viewType,
181185
})
182186

183187
// Only need to set `columnState` once, using the first table's column state

packages/next/src/views/List/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export const renderListView = async (
224224
req,
225225
trash,
226226
user,
227+
viewType,
227228
where: whereWithMergedSearch,
228229
}))
229230
} else {

0 commit comments

Comments
 (0)