Skip to content

Commit

Permalink
Merge pull request #93 from jangidgirish/master
Browse files Browse the repository at this point in the history
bug fixed add initial field in create mode
  • Loading branch information
yassilah authored Mar 12, 2020
2 parents 565ad16 + ad8bdad commit 4ecc2d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions resources/js/components/NestedFormAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default {
* Add a new child.
*/
addChild() {
const maxKey = this.field.children[this.field.children.length - 1].key || Math.max.apply(Math, this.field.children.map(({ id }) => id));
let maxKey = 0;
if(this.field.children.length){
maxKey = this.field.children[this.field.children.length - 1].key || Math.max.apply(Math, this.field.children.map(({ id }) => id));
}
this.field.schema.key = maxKey + 1;
this.field.children.push(this.replaceIndexesInSchema(this.field));
},
Expand Down Expand Up @@ -81,4 +84,4 @@ export default {
}
}
}
</script>
</script>

0 comments on commit 4ecc2d6

Please sign in to comment.