diff --git a/src/frontend/src/components/keypairListComponent/index.tsx b/src/frontend/src/components/keypairListComponent/index.tsx index be6ea1f64..ef30ac331 100644 --- a/src/frontend/src/components/keypairListComponent/index.tsx +++ b/src/frontend/src/components/keypairListComponent/index.tsx @@ -23,11 +23,16 @@ export default function KeypairListComponent({ const handleChangeKey = (event, idx) => { const newInputList = _.cloneDeep(value); const oldKey = Object.keys(newInputList[idx])[0]; - const updatedObj = { [event.target.value]: newInputList[idx][oldKey] }; - newInputList[idx] = updatedObj; + let counter = 1; + let newKey = event.target.value; + while (newInputList.some(obj => Object.keys(obj)[0] === newKey)) { + newKey = `${event.target.value}_${counter}`; + counter++; + } + newInputList[idx] = { [newKey]: newInputList[idx][oldKey] }; onChange(newInputList); }; - + const handleChangeValue = (newValue, idx) => { const newInputList = _.cloneDeep(value); const key = Object.keys(newInputList[idx])[0];