fix(next): group by null relationship crashes list view (#13315)

When grouping by a relationship field and it's value is `null`, the list
view crashes.

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210916642997992
This commit is contained in:
Jacob Fletcher
2025-07-29 11:55:02 -04:00
committed by GitHub
parent 61ee8fadca
commit e50220374e
2 changed files with 21 additions and 0 deletions

View File

@@ -144,6 +144,7 @@ export const handleGroupBy = async ({
if (
groupByField?.type === 'relationship' &&
potentiallyPopulatedRelationship &&
typeof potentiallyPopulatedRelationship === 'object'
) {
heading =

View File

@@ -236,6 +236,26 @@ test.describe('Group By', () => {
await expect(page.locator('.group-by-header')).toHaveCount(0)
})
test('should group by relationships even when their values are null', async () => {
await payload.create({
collection: postsSlug,
data: {
title: 'My Post',
category: null,
},
})
await page.goto(url.list)
await addGroupBy(page, { fieldLabel: 'Category', fieldPath: 'category' })
await expect(page.locator('.table-wrap')).toHaveCount(3)
await expect(
page.locator('.group-by-header__heading', { hasText: exactText('No value') }),
).toBeVisible()
})
test('should sort the group-by field globally', async () => {
await page.goto(url.list)