@@ -213,6 +213,11 @@ function FallbackColumn({ node, children }: StructureContainerProps) {
213213 ) ;
214214}
215215
216+ function FallbackGridComponent ( { node, children } : StructureContainerProps ) {
217+ const { pa } = getPreviewUtils ( node ) ;
218+ return < div { ...pa ( node ) } > { children } </ div > ;
219+ }
220+
216221function FallbackComponent ( { children } : { children : ReactNode } ) {
217222 return isDev ( ) ? (
218223 < div
@@ -234,45 +239,37 @@ type OptimizelyGridSectionProps = {
234239 nodes : ExperienceNode [ ] ;
235240 row ?: StructureContainer ;
236241 column ?: StructureContainer ;
242+ component ?: StructureContainer ;
237243 displaySettings ?: DisplaySettingsType [ ] ;
238244} ;
239245
240246const fallbacks : Record < string , StructureContainer > = {
241247 row : FallbackRow ,
242248 column : FallbackColumn ,
249+ component : FallbackGridComponent ,
243250} ;
244251
245252export function OptimizelyGridSection ( {
246253 nodes,
247254 row,
248255 column,
256+ component,
249257} : OptimizelyGridSectionProps ) {
250258 const locallyDefined : Record < string , StructureContainer | undefined > = {
251259 row,
252260 column,
261+ component,
253262 } ;
254263
255264 return nodes . map ( ( node , i ) => {
256265 const tag = getDisplayTemplateTag ( node . displayTemplateKey ) ;
257266 const parsedDisplaySettings = parseDisplaySettings ( node . displaySettings ) ;
258267
259- if ( isComponentNode ( node ) ) {
260- return (
261- < OptimizelyComponent
262- opti = { {
263- ...node . component ,
264- __tag : tag ,
265- } }
266- key = { node . key }
267- displaySettings = { parsedDisplaySettings }
268- />
269- ) ;
270- }
271-
272268 const { nodeType } = node ;
273269 const globalNames : Record < string , string > = {
274270 row : '_Row' ,
275271 column : '_Column' ,
272+ component : '_Component' ,
276273 } ;
277274
278275 // Pick the component in the following order:
@@ -286,6 +283,21 @@ export function OptimizelyGridSection({
286283 fallbacks [ nodeType ] ??
287284 React . Fragment ;
288285
286+ if ( isComponentNode ( node ) ) {
287+ return (
288+ < Component node = { node } index = { i } key = { node . key } >
289+ < OptimizelyComponent
290+ opti = { {
291+ ...node . component ,
292+ __tag : tag ,
293+ } }
294+ key = { node . key }
295+ displaySettings = { parsedDisplaySettings }
296+ />
297+ </ Component >
298+ ) ;
299+ }
300+
289301 return (
290302 < Component
291303 node = { node }
@@ -296,6 +308,7 @@ export function OptimizelyGridSection({
296308 < OptimizelyGridSection
297309 row = { row }
298310 column = { column }
311+ component = { component }
299312 nodes = { node . nodes ?? [ ] }
300313 />
301314 </ Component >
0 commit comments