Fix bug with duplication of fields when re-registering existing fields
This commit is contained in:
parent
9f30599ec1
commit
8e58cde6ec
|
@ -83,6 +83,8 @@
|
||||||
return fields.find(field => get(field).name === name)
|
return fields.find(field => get(field).name === name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: console.log(fields)
|
||||||
|
|
||||||
const formApi = {
|
const formApi = {
|
||||||
registerField: (
|
registerField: (
|
||||||
field,
|
field,
|
||||||
|
@ -136,7 +138,12 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add this field
|
// Add this field
|
||||||
fields = [...fields, fieldInfo]
|
if (existingField) {
|
||||||
|
const otherFields = fields.filter(info => get(info).name !== field)
|
||||||
|
fields = [...otherFields, fieldInfo]
|
||||||
|
} else {
|
||||||
|
fields = [...fields, fieldInfo]
|
||||||
|
}
|
||||||
|
|
||||||
return fieldInfo
|
return fieldInfo
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue