Skip to content

Commit 4ecc2d6

Browse files
authored
Merge pull request #93 from jangidgirish/master
bug fixed add initial field in create mode
2 parents 565ad16 + ad8bdad commit 4ecc2d6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/NestedFormAdd.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export default {
3030
* Add a new child.
3131
*/
3232
addChild() {
33-
const maxKey = this.field.children[this.field.children.length - 1].key || Math.max.apply(Math, this.field.children.map(({ id }) => id));
33+
let maxKey = 0;
34+
if(this.field.children.length){
35+
maxKey = this.field.children[this.field.children.length - 1].key || Math.max.apply(Math, this.field.children.map(({ id }) => id));
36+
}
3437
this.field.schema.key = maxKey + 1;
3538
this.field.children.push(this.replaceIndexesInSchema(this.field));
3639
},
@@ -81,4 +84,4 @@ export default {
8184
}
8285
}
8386
}
84-
</script>
87+
</script>

0 commit comments

Comments
 (0)