You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Register a Content Model Product
E.g., use the following code to implement a content model that has an attribute field isoCode nested within three different objects. It's field path would be metaData.generalMetaData.specificMetaData.isoCode.
2. Register a field decorator for Product
Here is an example decorator that calls the useParentField() hook multiple times to fetch all ancestor fields and logs them to console. This decorator is registered through the Apps.tsx for modelId product.
ProductRenderDecorator.tsx
importReactfrom"react";import{ContentEntryEditorConfig,useParentField}from"@webiny/app-headless-cms";const{ FieldElement }=ContentEntryEditorConfig;exportconstProductRenderDecorator=FieldElement.createDecorator(Original=>{returnfunctionConditionalRender(props){if(props.field.fieldId=="isoCode"){constparent=useParentField();constparent2=useParentField(1);constparent3=useParentField(2);console.log(`current field is ${parent?.path}.${props.field.fieldId}`);console.log(`1st level parent: ${parent?.field.fieldId}`);console.log(`2nd level parent: ${parent2?.field.fieldId}`);console.log(`3rd level parent: ${parent3?.field.fieldId}`);console.log("-1-");}return<Original{...props}/>;};});
What is the expected behavior?
The following console log is expected when loading a product content entry:
current field is metaData.generalMetaData.specificMetaData.isoCode
1st level parent: specificMetaData
2nd level parent: generalMetaData
3rd level parent: metaData
-1-
What do you see instead?
The following console log:
current field is metaData.generalMetaData.specificMetaData.isoCode
1st level parent: specificMetaData
2nd level parent: metaData
3rd level parent: undefined
-1-
Additional information
No response
Possible solution
This needs a fix in line no. 33 of ParentValue.tsx.
I'll provide a PR. 👍
The text was updated successfully, but these errors were encountered:
Version
v5.40.0-beta.4
Operating System
MacOS
Browser
Firefox 126.0.1
What are the steps to reproduce this bug?
1. Register a Content Model
Product
E.g., use the following code to implement a content model that has an attribute field
isoCode
nested within three different objects. It's field path would bemetaData.generalMetaData.specificMetaData.isoCode
.product.ts
2. Register a field decorator for
Product
Here is an example decorator that calls the
useParentField()
hook multiple times to fetch all ancestor fields and logs them to console. This decorator is registered through theApps.tsx
for modelIdproduct
.ProductRenderDecorator.tsx
What is the expected behavior?
The following console log is expected when loading a product content entry:
What do you see instead?
The following console log:
Additional information
No response
Possible solution
This needs a fix in line no. 33 of
ParentValue.tsx
.I'll provide a PR. 👍
The text was updated successfully, but these errors were encountered: