Skip to content

Commit 35fca95

Browse files
committed
backport PR #2631 to take into account additionalProperties set to false in schema
1 parent d197f68 commit 35fca95

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ should change the heading of the (upcoming) version to include a major version b
1616
1717
-->
1818
# v5.0.0 (coming soon)
19+
## @rjsf/utils
20+
- clear errors on formData change when liveOmit=true when "additionalProperties: false" [issue 1507](https://github.com/rjsf-team/react-jsonschema-form/issues/1507) (https://github.com/rjsf-team/react-jsonschema-form/pull/2631)
1921

2022
# 4.2.1 (upcoming)
2123

packages/utils/src/schema/toPathSchema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ export default function toPathSchema<T = any>(
3737
$name: name.replace(/^\./, ''),
3838
} as PathSchema;
3939

40-
if (ADDITIONAL_PROPERTIES_KEY in schema) {
40+
if (ADDITIONAL_PROPERTIES_KEY in schema &&
41+
schema[ADDITIONAL_PROPERTIES_KEY] !== false) {
4142
set(pathSchema, '__rjsf_additionalProperties', true);
4243
}
4344

packages/utils/test/schema/toPathSchemaTest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export default function toPathSchemaTest(testValidator: TestValidatorType) {
1313

1414
expect(toPathSchema(testValidator, schema)).toEqual({ $name: '', __rjsf_additionalProperties: true });
1515
});
16+
it('should return a pathSchema for root field, without additional properties', () => {
17+
const schema: RJSFSchema = { type: 'string', additionalProperties: false };
18+
19+
expect(toPathSchema(testValidator, schema)).toEqual({ $name: ''});
20+
});
1621
it('should return a pathSchema for nested objects', () => {
1722
const schema: RJSFSchema = {
1823
type: 'object',

0 commit comments

Comments
 (0)