Skip to content

Commit

Permalink
Moved seed validation from onChange event handler to onBlur event han…
Browse files Browse the repository at this point in the history
…dler (#363)
  • Loading branch information
Randy808 authored Jun 20, 2022
1 parent f803c47 commit 5cd0254
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/presentation/onboarding/wallet-restore/mnemonic-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export const MnemonicField: React.FC<Props> = ({ onChange, value }) => {
};

const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
if (!validSeed(event.target.value)) {
setError(undefined);
onChange(event.target.value);
};

const handleBlur = () => {
if (!validSeed(value)) {
setError('Mnemonic is not valid - should be 12 or 24 words separated by spaces');
onChange('');
} else {
setError(undefined);
onChange(event.target.value);
}
};

Expand All @@ -38,6 +39,7 @@ export const MnemonicField: React.FC<Props> = ({ onChange, value }) => {
}
)}
onChange={handleChange}
onBlur={handleBlur}
placeholder="Enter your mnemonic phrase"
value={value}
/>
Expand Down

0 comments on commit 5cd0254

Please sign in to comment.