diff --git a/CHANGELOG.md b/CHANGELOG.md index be2989de74..f642a8e449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,16 @@ should change the heading of the (upcoming) version to include a major version b --> -# 5.18.7 +# 5.18.6 + +## @rjsf/antd + +- Fix disabled property of options in CheckboxesWidget and RadioWidget ([#4216](https://github.com/rjsf-team/react-jsonschema-form/pull/4216)) + +## @rjsf/core + +- Fixed `omitExtraData` not working in `onSubmit` and `validateForm`; fixing [#4187](https://github.com/rjsf-team/react-jsonschema-form/issues/4187), [#4165](https://github.com/rjsf-team/react-jsonschema-form/issues/4165) and [#4109](https://github.com/rjsf-team/react-jsonschema-form/issues/4109) +- Fixed case where `readOnly` from a JSON Schema was not applied in SchemaField ([#4236](https://github.com/rjsf-team/react-jsonschema-form/issues/4236)) ## @rjsf/utils @@ -30,16 +39,6 @@ should change the heading of the (upcoming) version to include a major version b - Fix IdSchema and PathSchema types ([#4196](https://github.com/rjsf-team/react-jsonschema-form/pull/4196)) -# 5.18.6 - -## @rjsf/antd - -- Fix disabled property of options in CheckboxesWidget and RadioWidget ([#4216](https://github.com/rjsf-team/react-jsonschema-form/pull/4216)) - -## @rjsf/core - -- Fixed `omitExtraData` not working in `onSubmit` and `validateForm`; fixing [#4187](https://github.com/rjsf-team/react-jsonschema-form/issues/4187), [#4165](https://github.com/rjsf-team/react-jsonschema-form/issues/4165) and [#4109](https://github.com/rjsf-team/react-jsonschema-form/issues/4109) - # 5.18.5 ## @rjsf/antd diff --git a/packages/core/src/components/fields/SchemaField.tsx b/packages/core/src/components/fields/SchemaField.tsx index 1bf1f66d65..5ac131609a 100644 --- a/packages/core/src/components/fields/SchemaField.tsx +++ b/packages/core/src/components/fields/SchemaField.tsx @@ -151,7 +151,7 @@ function SchemaFieldRender(schema, uiOptions, idSchema, registry); const disabled = Boolean(uiOptions.disabled ?? props.disabled); - const readonly = Boolean(uiOptions.readonly ?? props.readonly ?? props.schema.readOnly ?? schema.readOnly); + const readonly = Boolean(uiOptions.readonly ?? (props.readonly || props.schema.readOnly || schema.readOnly)); const uiSchemaHideError = uiOptions.hideError; // Set hideError to the value provided in the uiSchema, otherwise stick with the prop to propagate to children const hideError = uiSchemaHideError === undefined ? props.hideError : Boolean(uiSchemaHideError); diff --git a/packages/core/test/SchemaField.test.jsx b/packages/core/test/SchemaField.test.jsx index f243a5c864..1a82d3f247 100644 --- a/packages/core/test/SchemaField.test.jsx +++ b/packages/core/test/SchemaField.test.jsx @@ -847,4 +847,23 @@ describe('SchemaField', () => { expect(textContent).to.contains(descText); }); }); + + describe('readOnly', () => { + const schema = { + type: 'object', + properties: { + foo: { type: 'boolean', readOnly: true }, + }, + }; + + it('should be readonly if prescribed by the schema', () => { + const { node } = createFormComponent({ + schema, + }); + + const { disabled } = node.querySelector('input'); + + expect(disabled).to.eq(true); + }); + }); });