Skip to content

Commit 565ad16

Browse files
authored
Merge pull request #80 from andriyPalko/master
Fix issue #18
2 parents 9fcb838 + 7753475 commit 565ad16

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

resources/js/components/NestedFormAdd.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export default {
3030
* Add a new child.
3131
*/
3232
addChild() {
33-
this.field.children.push(this.replaceIndexesInSchema(this.field))
33+
const maxKey = this.field.children[this.field.children.length - 1].key || Math.max.apply(Math, this.field.children.map(({ id }) => id));
34+
this.field.schema.key = maxKey + 1;
35+
this.field.children.push(this.replaceIndexesInSchema(this.field));
3436
},
3537
3638
/**

resources/js/components/NestedFormField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<template v-if="field.children.length > 0">
55
<card
66
:class="{ 'overflow-hidden': field.panel && !index }"
7-
:key="childIndex"
7+
:key="child.id || child.key"
88
v-for="(child, childIndex) in field.children"
99
>
1010
<nested-form-header

0 commit comments

Comments
 (0)