Skip to content

Commit

Permalink
Merge pull request #75 from batzionb/2561backport
Browse files Browse the repository at this point in the history
fix(orchestrator): pass also initial form data to custom decorator
  • Loading branch information
batzionb authored Nov 26, 2024
2 parents 08f6a06 + 524aced commit 359fb6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type FormDecoratorProps = Pick<FormProps<JsonObject, JSONSchema7>, 'formD

// @public
export interface OrchestratorFormApi {
getFormDecorator(schema: JSONSchema7, uiSchema: UiSchema<JsonObject, JSONSchema7>): OrchestratorFormDecorator;
getFormDecorator(schema: JSONSchema7, uiSchema: UiSchema<JsonObject, JSONSchema7>, initialFormData?: JsonObject): OrchestratorFormDecorator;
}

// @public
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface OrchestratorFormApi {
getFormDecorator(
schema: JSONSchema7,
uiSchema: UiSchema<JsonObject, JSONSchema7>,
initialFormData?: JsonObject,
): OrchestratorFormDecorator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,19 @@ const FormComponent = (decoratorProps: FormDecoratorProps) => {
const OrchestratorFormWrapper = ({
schema,
uiSchema,
formData,
...props
}: OrchestratorFormWrapperProps) => {
const formApi =
useApiHolder().get(orchestratorFormApiRef) || defaultFormExtensionsApi;
const NewComponent = React.useMemo(() => {
const formDecorator = formApi.getFormDecorator(schema, uiSchema);
const formDecorator = formApi.getFormDecorator(schema, uiSchema, formData);
return formDecorator(FormComponent);
}, [schema, formApi, uiSchema]);
}, [schema, formApi, uiSchema, formData]);
return (
<WrapperFormPropsContext.Provider value={{ schema, uiSchema, ...props }}>
<WrapperFormPropsContext.Provider
value={{ schema, uiSchema, formData, ...props }}
>
<NewComponent />
</WrapperFormPropsContext.Provider>
);
Expand Down

0 comments on commit 359fb6a

Please sign in to comment.