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,36 +54,35 @@ export const CreateAccount = ({ onActionComplete }) => {
}
};
return (
<Box
as="form"
onSubmit={async (event) => {
event.preventDefault();
const onSubmit = async (event) => {
event.preventDefault();
try {
await onCreateAccount(newAccountName || defaultAccountName);
onActionComplete(true);
trackEvent({
category: MetaMetricsEventCategory.Accounts,
event: MetaMetricsEventName.AccountAdded,
properties: {
account_type: MetaMetricsEventAccountType.Default,
location: 'Home',
},
});
history.push(mostRecentOverviewPage);
} catch (error) {
trackEvent({
category: MetaMetricsEventCategory.Accounts,
event: MetaMetricsEventName.AccountAddFailed,
properties: {
account_type: MetaMetricsEventAccountType.Default,
error: error.message,
},
});
}
}}
>
try {
await onCreateAccount(newAccountName || defaultAccountName);
onActionComplete(true);
trackEvent({
category: MetaMetricsEventCategory.Accounts,
event: MetaMetricsEventName.AccountAdded,
properties: {
account_type: MetaMetricsEventAccountType.Default,
location: 'Home',
},
});
history.push(mostRecentOverviewPage);
} catch (error) {
trackEvent({
category: MetaMetricsEventCategory.Accounts,
event: MetaMetricsEventName.AccountAddFailed,
properties: {
account_type: MetaMetricsEventAccountType.Default,
error: error.message,
},
});
}
};
return (
<Box as="form" onSubmit={onSubmit}>
<FormTextField
autoFocus
label={t('accountName')}
@ -91,6 +90,11 @@ export const CreateAccount = ({ onActionComplete }) => {
onChange={(event) => setNewAccountName(event.target.value)}
helpText={errorMessage}
error={!isValidAccountName}
onKeyPress={(e) => {
if (e.key === 'Enter') {
onSubmit(e);
}
}}
/>
<Box display={Display.Flex} marginTop={6} gap={2}>
<ButtonSecondary onClick={() => onActionComplete()} block>