1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix #19619 - Submit the account creation form when pressing enter (#19620)

This commit is contained in:
David Walsh 2023-06-16 08:13:08 -05:00 committed by GitHub
parent 1aae94fedc
commit bc2a5aaf96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,10 +54,7 @@ export const CreateAccount = ({ onActionComplete }) => {
} }
}; };
return ( const onSubmit = async (event) => {
<Box
as="form"
onSubmit={async (event) => {
event.preventDefault(); event.preventDefault();
try { try {
@ -82,8 +79,10 @@ export const CreateAccount = ({ onActionComplete }) => {
}, },
}); });
} }
}} };
>
return (
<Box as="form" onSubmit={onSubmit}>
<FormTextField <FormTextField
autoFocus autoFocus
label={t('accountName')} label={t('accountName')}
@ -91,6 +90,11 @@ export const CreateAccount = ({ onActionComplete }) => {
onChange={(event) => setNewAccountName(event.target.value)} onChange={(event) => setNewAccountName(event.target.value)}
helpText={errorMessage} helpText={errorMessage}
error={!isValidAccountName} error={!isValidAccountName}
onKeyPress={(e) => {
if (e.key === 'Enter') {
onSubmit(e);
}
}}
/> />
<Box display={Display.Flex} marginTop={6} gap={2}> <Box display={Display.Flex} marginTop={6} gap={2}>
<ButtonSecondary onClick={() => onActionComplete()} block> <ButtonSecondary onClick={() => onActionComplete()} block>