diff --git a/src/jsonData.js b/src/jsonData.js index a28987e..abeaf31 100644 --- a/src/jsonData.js +++ b/src/jsonData.js @@ -46,7 +46,10 @@ export function changeProperty (data, path, oldProp, newProp) { const object = getIn(data, dataPath) const index = object.props.findIndex(p => p.name === oldProp) - return setIn(data, dataPath.concat(['props', index, 'name']), newProp) + // prevent duplicate property names + const uniqueNewProp = findUniqueName(newProp, object.props.map(p => p.name)) + + return setIn(data, dataPath.concat(['props', index, 'name']), uniqueNewProp) } /** @@ -173,6 +176,9 @@ export function duplicate (data, path, prop) { const original = props[index] const duplicate = cloneDeep(original) + // prevent duplicate property names + duplicate.name = findUniqueName(duplicate.name, props.map(p => p.name)) + updated.splice(index + 1, 0, duplicate) return updated