diff --git a/CHANGELOG.md b/CHANGELOG.md index 72262914c1..2977fc5b1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,12 @@ it according to semantic versioning. For example, if your PR adds a breaking cha should change the heading of the (upcoming) version to include a major version bump. --> +# 5.15.1 + +## @rjsf/core + +- fix `getFieldNames`. Now correctly defines an array of primitives. + # 5.15.0 ## @rjsf/mui diff --git a/packages/core/src/components/Form.tsx b/packages/core/src/components/Form.tsx index a8180521ef..101287edcf 100644 --- a/packages/core/src/components/Form.tsx +++ b/packages/core/src/components/Form.tsx @@ -533,7 +533,11 @@ export default class Form< const formValue = _get(formData, path); // adds path to fieldNames if it points to a value // or an empty object/array - if (typeof formValue !== 'object' || _isEmpty(formValue)) { + if ( + typeof formValue !== 'object' || + _isEmpty(formValue) || + (Array.isArray(formValue) && formValue.every((val) => typeof val !== 'object')) + ) { acc.push(path); } }); diff --git a/packages/core/test/Form.test.jsx b/packages/core/test/Form.test.jsx index 3038224e36..43c4f43804 100644 --- a/packages/core/test/Form.test.jsx +++ b/packages/core/test/Form.test.jsx @@ -3463,6 +3463,7 @@ describe('Form omitExtraData and liveOmit', () => { extra: 'asdf', anotherThingNested2: 0, }, + stringArray: ['scobochka'], }, level1a: 1.23, }; @@ -3488,6 +3489,9 @@ describe('Form omitExtraData and liveOmit', () => { $name: 'level1.anotherThing.anotherThingNested2', }, }, + stringArray: { + $name: 'level1.stringArray', + }, }, level1a: { $name: 'level1a', @@ -3500,6 +3504,7 @@ describe('Form omitExtraData and liveOmit', () => { ['level1', 'anotherThing', 'anotherThingNested'], ['level1', 'anotherThing', 'anotherThingNested2'], ['level1', 'level2'], + ['level1', 'stringArray'], ['level1a'], ].sort() );