1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

UX: Allow quick Add Account name based on default name (#20168)

* UX: Allow quick Add Account name

* do not allow account names with just spaces

---------

Co-authored-by: Howard Braham <howrad@gmail.com>
This commit is contained in:
David Walsh 2023-07-26 20:03:30 -05:00 committed by GitHub
parent 811d25c636
commit f584f56d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -39,11 +39,12 @@ export const CreateAccount = ({ onActionComplete }) => {
const defaultAccountName = t('newAccountNumberName', [newAccountNumber]); const defaultAccountName = t('newAccountNumberName', [newAccountNumber]);
const [newAccountName, setNewAccountName] = useState(''); const [newAccountName, setNewAccountName] = useState('');
const trimmedAccountName = newAccountName.trim();
const { isValidAccountName, errorMessage } = getAccountNameErrorMessage( const { isValidAccountName, errorMessage } = getAccountNameErrorMessage(
accounts, accounts,
{ t }, { t },
newAccountName, trimmedAccountName ?? defaultAccountName,
defaultAccountName, defaultAccountName,
); );
@ -58,7 +59,7 @@ export const CreateAccount = ({ onActionComplete }) => {
event.preventDefault(); event.preventDefault();
try { try {
await onCreateAccount(newAccountName || defaultAccountName); await onCreateAccount(trimmedAccountName || defaultAccountName);
onActionComplete(true); onActionComplete(true);
trackEvent({ trackEvent({
category: MetaMetricsEventCategory.Accounts, category: MetaMetricsEventCategory.Accounts,

View File

@ -38,7 +38,7 @@ export default class EditableLabel extends Component {
return; return;
} }
await this.props.onSubmit(this.state.value); await this.props.onSubmit(this.state.value.trim());
this.setState({ isEditing: false }); this.setState({ isEditing: false });
} }