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:
@@ -144,6 +144,7 @@ export const handleGroupBy = async ({
|
||||
|
||||
if (
|
||||
groupByField?.type === 'relationship' &&
|
||||
potentiallyPopulatedRelationship &&
|
||||
typeof potentiallyPopulatedRelationship === 'object'
|
||||
) {
|
||||
heading =
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user