File tree Expand file tree Collapse file tree 4 files changed +28
-27
lines changed
packages/next/src/views/List Expand file tree Collapse file tree 4 files changed +28
-27
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ export const handleGroupBy = async ({
143
143
} ,
144
144
} )
145
145
146
- let heading = valueOrRelationshipID || req . i18n . t ( 'general:noValue' )
146
+ let heading = valueOrRelationshipID
147
147
148
148
if (
149
149
groupByField ?. type === 'relationship' &&
@@ -155,9 +155,9 @@ export const handleGroupBy = async ({
155
155
valueOrRelationshipID
156
156
}
157
157
158
- if ( groupByField . type === 'date' ) {
158
+ if ( groupByField . type === 'date' && valueOrRelationshipID ) {
159
159
heading = formatDate ( {
160
- date : String ( heading ) ,
160
+ date : String ( valueOrRelationshipID ) ,
161
161
i18n : req . i18n ,
162
162
pattern : clientConfig . admin . dateFormat ,
163
163
} )
@@ -174,7 +174,7 @@ export const handleGroupBy = async ({
174
174
enableRowSelections,
175
175
groupByFieldPath,
176
176
groupByValue : valueOrRelationshipID ,
177
- heading,
177
+ heading : heading || req . i18n . t ( 'general:noValue' ) ,
178
178
i18n : req . i18n ,
179
179
key : `table-${ valueOrRelationshipID } ` ,
180
180
orderableFieldName : collectionConfig . orderable === true ? '_order' : undefined ,
Original file line number Diff line number Diff line change 1
1
import type { CollectionConfig } from 'payload'
2
2
3
- import { lexicalEditor } from '@payloadcms/richtext-lexical'
4
-
5
3
import { categoriesSlug } from '../Categories/index.js'
6
4
7
5
export const postsSlug = 'posts'
@@ -25,11 +23,8 @@ export const PostsCollection: CollectionConfig = {
25
23
relationTo : categoriesSlug ,
26
24
} ,
27
25
{
28
- name : 'content' ,
29
- type : 'richText' ,
30
- editor : lexicalEditor ( {
31
- features : ( { defaultFeatures } ) => [ ...defaultFeatures ] ,
32
- } ) ,
26
+ name : 'date' ,
27
+ type : 'date' ,
33
28
} ,
34
29
{
35
30
type : 'tabs' ,
Original file line number Diff line number Diff line change @@ -245,6 +245,26 @@ test.describe('Group By', () => {
245
245
) . toBeVisible ( )
246
246
} )
247
247
248
+ test ( 'should group by date fields even when their values are null' , async ( ) => {
249
+ await payload . create ( {
250
+ collection : postsSlug ,
251
+ data : {
252
+ title : 'My Post' ,
253
+ date : null ,
254
+ } ,
255
+ } )
256
+
257
+ await page . goto ( url . list )
258
+
259
+ await addGroupBy ( page , { fieldLabel : 'Date' , fieldPath : 'date' } )
260
+
261
+ await expect ( page . locator ( '.table-wrap' ) ) . toHaveCount ( 1 )
262
+
263
+ await expect (
264
+ page . locator ( '.group-by-header__heading' , { hasText : exactText ( 'No value' ) } ) ,
265
+ ) . toBeVisible ( )
266
+ } )
267
+
248
268
test ( 'should sort the group-by field globally' , async ( ) => {
249
269
await page . goto ( url . list )
250
270
Original file line number Diff line number Diff line change @@ -125,21 +125,7 @@ export interface Post {
125
125
id : string ;
126
126
title ?: string | null ;
127
127
category ?: ( string | null ) | Category ;
128
- content ?: {
129
- root : {
130
- type : string ;
131
- children : {
132
- type : string ;
133
- version : number ;
134
- [ k : string ] : unknown ;
135
- } [ ] ;
136
- direction : ( 'ltr' | 'rtl' ) | null ;
137
- format : 'left' | 'start' | 'center' | 'right' | 'end' | 'justify' | '' ;
138
- indent : number ;
139
- version : number ;
140
- } ;
141
- [ k : string ] : unknown ;
142
- } | null ;
128
+ date ?: string | null ;
143
129
tab1Field ?: string | null ;
144
130
updatedAt : string ;
145
131
createdAt : string ;
@@ -295,7 +281,7 @@ export interface PayloadMigration {
295
281
export interface PostsSelect < T extends boolean = true > {
296
282
title ?: T ;
297
283
category ?: T ;
298
- content ?: T ;
284
+ date ?: T ;
299
285
tab1Field ?: T ;
300
286
updatedAt ?: T ;
301
287
createdAt ?: T ;
You can’t perform that action at this time.
0 commit comments