diff --git a/packages/react/src/JsonFormsContext.tsx b/packages/react/src/JsonFormsContext.tsx index c976607f8..5bb6ee2cb 100644 --- a/packages/react/src/JsonFormsContext.tsx +++ b/packages/react/src/JsonFormsContext.tsx @@ -158,7 +158,7 @@ export const JsonFormsStateProvider = ({ children, initState, onChange }: any) = i18n: i18n, // only core dispatch available dispatch: coreDispatch, - }), [core, initState.renderers, initState.cells, config, initState.readonly, i18n]); + }), [core, initState.renderers, initState.cells, config, initState.uischemas, initState.readonly, i18n]); const onChangeRef = useRef(onChange); useEffect(() => { diff --git a/packages/react/test/JsonFormsContext.test.tsx b/packages/react/test/JsonFormsContext.test.tsx index f83b681c7..93ea8a14f 100644 --- a/packages/react/test/JsonFormsContext.test.tsx +++ b/packages/react/test/JsonFormsContext.test.tsx @@ -264,3 +264,70 @@ test('withJsonFormsDetailProps - should use uischemas props', () => { expect(mockUISchemasProps.schema).toEqual(schema); expect(mockUISchemasProps.uischemas).toEqual(uischemas); }); + +test('withJsonFormsDetailProps - should update uischemas after change', () => { + const MockUISchemas = (_: StatePropsOfControlWithDetail) => { + return <>; + }; + + const MockBasicRenderer = withJsonFormsDetailProps(MockUISchemas); + + const schema = { + type: 'object', + properties: { + foo: { + type: 'string', + }, + bar: { + type: 'number' + } + } + }; + + const renderers = [ + { + tester: rankWith(1, () => true), + renderer: MockBasicRenderer + } + ]; + + const newUischemas = [ + { + tester: (_jsonSchema: JsonSchema, schemaPath: string) => { + return schemaPath === '#/properties/color' ? 2 : NOT_APPLICABLE; + }, + uischema: { + type: 'HorizontalLayout', + elements: [ + { + type: 'Control', + scope: '#/properties/foo' + }, + { + type: 'Control', + scope: '#/properties/bar' + } + ] + } + } + ]; + + const uischema = { + type: 'Control', + scope: '#' + }; + + const wrapper = mount( + + ); + + wrapper.setProps({ uischemas: newUischemas }); + wrapper.update(); + const mockUISchemasProps = wrapper.find(MockUISchemas).props(); + expect(mockUISchemasProps.uischemas).toEqual(newUischemas); +});