Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
fix(steps-details): Required object type's parameters are lost
Browse files Browse the repository at this point in the history
Currently, having a step with a required object type parameter
gets removed from the Code Editor upon opening the step's details
panel.

This issue occurs because we're instructing `uniforms` that we have
a required object property without a default or initial value.

Once `uniforms` tries to build the initial form value, it returns an
empty object. [This happens here](https://github.com/vazco/uniforms/blob/ecb1785468bfe2508399a48e13bdb921549ab91a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts#L267-L276).

Considering that there are no current plans to support object property
definitions, the workaround is to provide a default value alongside
the schema to feed the initial value of object properties.

Fixes: #1603
  • Loading branch information
lordrip committed Mar 31, 2023
1 parent 9405caa commit 1484087
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
4 changes: 0 additions & 4 deletions src/components/CustomJsonSchemaBridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import JSONSchemaBridge from 'uniforms-bridge-json-schema';
* based on the incoming model data
*/
export class CustomJsonSchemaBridge extends JSONSchemaBridge {
constructor(schema: any, validator: any) {
super(schema, validator);
}

getField(name: string): Record<string, any> {
const field = super.getField(name);
const { defaultValue, description, ...props } = field;
Expand Down
1 change: 1 addition & 0 deletions src/components/VisualizationStepViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const VisualizationStepViews = ({
type: 'object',
properties: stepPropertySchema,
required: step.required,
default: stepPropertyModel,
}}
configuration={stepPropertyModel}
parametersOrder={parametersOrder}
Expand Down

0 comments on commit 1484087

Please sign in to comment.