@@ -84,7 +84,7 @@ type OptimizelyComponentProps = {
8484 /** Preview context */
8585 __context ?: { edit : boolean ; preview_token : string } ;
8686
87- composition ?: ExperienceCompositionNode ;
87+ __composition ?: ExperienceCompositionNode ;
8888 } ;
8989
9090 displaySettings ?: Record < string , string > ;
@@ -98,7 +98,8 @@ export async function OptimizelyComponent({
9898 if ( ! componentRegistry ) {
9999 throw new Error ( 'You should call `initReactComponentRegistry` first' ) ;
100100 }
101- const dtKey = opti . composition ?. displayTemplateKey ?? opti . displayTemplateKey ;
101+ const dtKey =
102+ opti . __composition ?. displayTemplateKey ?? opti . displayTemplateKey ;
102103 const Component = await componentRegistry . getComponent ( opti . __typename , {
103104 tag : opti . __tag ?? getDisplayTemplateTag ( dtKey ) ,
104105 } ) ;
@@ -260,7 +261,9 @@ export function OptimizelyGridSection({
260261 return (
261262 < OptimizelyComponent
262263 opti = { {
264+ // `node.component` contains user-defined properties
263265 ...node . component ,
266+ __composition : node ,
264267 __tag : tag ,
265268 } }
266269 key = { node . key }
@@ -307,17 +310,19 @@ export function OptimizelyGridSection({
307310export function getPreviewUtils ( opti : OptimizelyComponentProps [ 'opti' ] ) {
308311 return {
309312 /** Get the HTML data attributes required for a property */
310- pa ( property : string | { key : string } ) {
313+ pa ( property ? : string | { key : string } ) {
311314 if ( opti . __context ?. edit ) {
312315 if ( typeof property === 'string' ) {
313316 return {
314317 'data-epi-property-name' : property ,
315318 } ;
316- } else {
319+ } else if ( property ) {
317320 return {
318321 'data-epi-block-id' : property . key ,
319322 } ;
320323 }
324+
325+ return { } ;
321326 } else {
322327 return { } ;
323328 }
0 commit comments