Skip to content

Commit 9b88077

Browse files
committed
Fix undefined property error when dependencies are out of order (issue #337)
1 parent 25ff7b0 commit 9b88077

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/formBuilder/utils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,8 @@ export function generateElementPropsFromSchemas(parameters: {
520520
if (group.oneOf) {
521521
let possibilityIndex = 0;
522522
group.oneOf.forEach((possibility) => {
523-
if (!elementDict[parent].dependents) {
523+
if (!(elementDict[parent] || {}).dependents) {
524+
elementDict[parent] = elementDict[parent] || {};
524525
elementDict[parent].dependents = [];
525526
}
526527
elementDict[parent].dependents.push({
@@ -636,7 +637,8 @@ export function countElementsFromSchema(schemaData: any): number {
636637
if (group.oneOf) {
637638
let possibilityIndex = 0;
638639
group.oneOf.forEach((possibility) => {
639-
if (!elementDict[parent].dependents) {
640+
if (!(elementDict[parent] || {}).dependents) {
641+
elementDict[parent] = elementDict[parent] || {};
640642
elementDict[parent].dependents = [];
641643
}
642644
elementDict[parent].dependents.push({
@@ -662,7 +664,7 @@ export function countElementsFromSchema(schemaData: any): number {
662664
});
663665
} else if (group.properties) {
664666
Object.entries(group.properties).forEach(([parameter]) => {
665-
elementDict[parameter] = {};
667+
elementDict[parameter] = elementDict[parameter] || {};
666668
elementCount += 1;
667669
if (elementDict[parent].dependents) {
668670
elementDict[parent].dependents[0].children.push(parameter);

0 commit comments

Comments
 (0)