Skip to content

Commit 7753475

Browse files
committed
fix issue #18
1 parent 24360aa commit 7753475

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)