From 92e5bdf89c314acc391e37eb991f65eda2dca402 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Fri, 1 Sep 2023 15:08:42 +0300 Subject: [PATCH] feat: add different ways to paste mnemonic --- .../KeyGeneration/AutocompleteInput.tsx | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/pages/ValidatorOnboarding/KeyGeneration/AutocompleteInput.tsx b/src/pages/ValidatorOnboarding/KeyGeneration/AutocompleteInput.tsx index 25612fc2..c126d476 100644 --- a/src/pages/ValidatorOnboarding/KeyGeneration/AutocompleteInput.tsx +++ b/src/pages/ValidatorOnboarding/KeyGeneration/AutocompleteInput.tsx @@ -20,21 +20,17 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => { const handleInputChange = (e: React.ChangeEvent) => { const value = e.target.value + const mnemonic = value.trim().split(' ') + const mnemonicLength = mnemonic.length - if (value.split(' ').length > 1) { - const mnemonic = value.trim().split(' ') - - if (mnemonic.length < 24) { - for (let i = 0; i < 24; i++) { - if (!mnemonic[i]) { - mnemonic.push('') - } - } - } - + if (mnemonicLength === 1) { + dispatch(setWord({ index, word: value })) + } else if (mnemonicLength === 24) { dispatch(setMnemonic(mnemonic)) } else { - dispatch(setWord({ index, word: value })) + for (let i = index; i < mnemonicLength + index; i++) { + dispatch(setWord({ index: i, word: mnemonic.shift() || '' })) + } } }