Skip to content

Commit 78327aa

Browse files
AriqunRozamo
authored andcommitted
Make getFieldNames correctly defines array of primitives (rjsf-team#3990)
1 parent 4b67dd8 commit 78327aa

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ it according to semantic versioning. For example, if your PR adds a breaking cha
1515
should change the heading of the (upcoming) version to include a major version bump.
1616
1717
-->
18+
# 5.15.1
19+
20+
## @rjsf/core
21+
22+
- fix `getFieldNames`. Now correctly defines an array of primitives.
23+
1824
# 5.15.0
1925

2026
## @rjsf/mui

packages/core/src/components/Form.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,11 @@ export default class Form<
533533
const formValue = _get(formData, path);
534534
// adds path to fieldNames if it points to a value
535535
// or an empty object/array
536-
if (typeof formValue !== 'object' || _isEmpty(formValue)) {
536+
if (
537+
typeof formValue !== 'object' ||
538+
_isEmpty(formValue) ||
539+
(Array.isArray(formValue) && formValue.every((val) => typeof val !== 'object'))
540+
) {
537541
acc.push(path);
538542
}
539543
});

packages/core/test/Form.test.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -3463,6 +3463,7 @@ describe('Form omitExtraData and liveOmit', () => {
34633463
extra: 'asdf',
34643464
anotherThingNested2: 0,
34653465
},
3466+
stringArray: ['scobochka'],
34663467
},
34673468
level1a: 1.23,
34683469
};
@@ -3488,6 +3489,9 @@ describe('Form omitExtraData and liveOmit', () => {
34883489
$name: 'level1.anotherThing.anotherThingNested2',
34893490
},
34903491
},
3492+
stringArray: {
3493+
$name: 'level1.stringArray',
3494+
},
34913495
},
34923496
level1a: {
34933497
$name: 'level1a',
@@ -3500,6 +3504,7 @@ describe('Form omitExtraData and liveOmit', () => {
35003504
['level1', 'anotherThing', 'anotherThingNested'],
35013505
['level1', 'anotherThing', 'anotherThingNested2'],
35023506
['level1', 'level2'],
3507+
['level1', 'stringArray'],
35033508
['level1a'],
35043509
].sort()
35053510
);

0 commit comments

Comments
 (0)