-
Notifications
You must be signed in to change notification settings - Fork 2
Fix dashboard stories schema and SchemaRenderer prop spreading #286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,9 +55,26 @@ export const SchemaRenderer = forwardRef<any, { schema: SchemaNode } & Record<st | |
|
|
||
| // Note: We don't forward the ref to the Component because components in the registry | ||
| // may not support refs. The SchemaRenderer itself can still receive refs for its own use. | ||
|
|
||
| // Extract schema metadata properties that should NOT be passed as React props | ||
| const { | ||
| type: _type, | ||
| children: _children, | ||
| body: _body, | ||
| schema: _schema, | ||
| visible: _visible, | ||
| visibleOn: _visibleOn, | ||
| hidden: _hidden, | ||
| hiddenOn: _hiddenOn, | ||
| disabled: _disabled, | ||
| disabledOn: _disabledOn, | ||
| ...componentProps | ||
| } = evaluatedSchema; | ||
|
Comment on lines
+59
to
+72
|
||
|
|
||
| return React.createElement(Component, { | ||
| schema: evaluatedSchema, | ||
| ...(evaluatedSchema.props || {}), | ||
| ...componentProps, // Spread non-metadata schema properties as props | ||
| ...(evaluatedSchema.props || {}), // Override with explicit props if provided | ||
|
Comment on lines
+60
to
+77
|
||
| className: evaluatedSchema.className, | ||
|
Comment on lines
+76
to
78
|
||
| 'data-obj-id': evaluatedSchema.id, | ||
|
Comment on lines
+60
to
79
|
||
| 'data-obj-type': evaluatedSchema.type, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
schemaproperty is being filtered out on line 64, but this might cause issues because the entire schema object is already being passed explicitly as a prop on line 75:schema: evaluatedSchema.Filtering out
schemafromcomponentPropsis correct to avoid passing it twice, but the variable name_schemais misleading - it suggests this is the schema being filtered out, when actually it's a property NAMED 'schema' that might exist on the evaluatedSchema object.For clarity, consider renaming this to indicate it's a property collision being avoided:
This makes it clear that we're filtering out any schema property that might exist on the object to avoid conflicting with the explicit
schemaprop being passed on line 75.