@@ -18,6 +18,7 @@ import type { Payload } from '../../types/index.js'
18
18
import { MissingEditorProp } from '../../errors/MissingEditorProp.js'
19
19
import { fieldAffectsData } from '../../fields/config/types.js'
20
20
import { flattenTopLevelFields } from '../../index.js'
21
+ import { removeUndefined } from '../../utilities/removeUndefined.js'
21
22
22
23
// Should not be used - ClientField should be used instead. This is why we don't export ClientField, we don't want people
23
24
// to accidentally use it instead of ClientField and get confused
@@ -99,8 +100,9 @@ export const createClientField = ({
99
100
clientField . admin . style = {
100
101
...clientField . admin . style ,
101
102
'--field-width' : clientField . admin . width ,
102
- width : undefined , // avoid needlessly adding this to the element's style attribute
103
103
}
104
+
105
+ delete clientField . admin . style . width // avoid needlessly adding this to the element's style attribute
104
106
} else {
105
107
if ( ! ( clientField . admin . style instanceof Object ) ) {
106
108
clientField . admin . style = { }
@@ -137,19 +139,24 @@ export const createClientField = ({
137
139
if ( incomingField . blocks ?. length ) {
138
140
for ( let i = 0 ; i < incomingField . blocks . length ; i ++ ) {
139
141
const block = incomingField . blocks [ i ]
140
- const clientBlock : ClientBlock = {
142
+
143
+ // prevent $undefined from being passed through the rsc requests
144
+ const clientBlock = removeUndefined < ClientBlock > ( {
141
145
slug : block . slug ,
142
- admin : {
143
- components : { } ,
144
- custom : block . admin ?. custom ,
145
- } ,
146
146
fields : field . blocks ?. [ i ] ?. fields || [ ] ,
147
147
imageAltText : block . imageAltText ,
148
148
imageURL : block . imageURL ,
149
+ } ) satisfies ClientBlock
150
+
151
+ if ( block . admin ?. custom ) {
152
+ clientBlock . admin = {
153
+ custom : block . admin . custom ,
154
+ }
149
155
}
150
156
151
157
if ( block . labels ) {
152
158
clientBlock . labels = { } as unknown as LabelsClient
159
+
153
160
if ( block . labels . singular ) {
154
161
if ( typeof block . labels . singular === 'function' ) {
155
162
clientBlock . labels . singular = block . labels . singular ( { t : i18n . t } )
@@ -184,6 +191,7 @@ export const createClientField = ({
184
191
185
192
case 'radio' :
186
193
194
+ // eslint-disable-next-line no-fallthrough
187
195
case 'select' : {
188
196
const field = clientField as RadioFieldClient | SelectFieldClient
189
197
@@ -206,7 +214,6 @@ export const createClientField = ({
206
214
207
215
break
208
216
}
209
-
210
217
case 'richText' : {
211
218
if ( ! incomingField ?. editor ) {
212
219
throw new MissingEditorProp ( incomingField ) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor
@@ -218,6 +225,7 @@ export const createClientField = ({
218
225
219
226
break
220
227
}
228
+
221
229
case 'tabs' : {
222
230
const field = clientField as unknown as TabsFieldClient
223
231
@@ -325,7 +333,6 @@ export const createClientFields = ({
325
333
} ,
326
334
hidden : true ,
327
335
label : 'ID' ,
328
- localized : undefined ,
329
336
} )
330
337
}
331
338
0 commit comments