Skip to content

Commit

Permalink
do not allow account names with just spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardBraham committed Jul 25, 2023
1 parent 12fc72f commit 9c6e8db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ui/components/multichain/create-account/create-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ export const CreateAccount = ({ onActionComplete }) => {
const defaultAccountName = t('newAccountNumberName', [newAccountNumber]);

const [newAccountName, setNewAccountName] = useState('');
const trimmedAccountName = newAccountName.trim();

const { isValidAccountName, errorMessage } = getAccountNameErrorMessage(
accounts,
{ t },
newAccountName === '' ? defaultAccountName : newAccountName,
trimmedAccountName ?? defaultAccountName,
defaultAccountName,
);

Expand All @@ -58,7 +59,7 @@ export const CreateAccount = ({ onActionComplete }) => {
event.preventDefault();

try {
await onCreateAccount(newAccountName || defaultAccountName);
await onCreateAccount(trimmedAccountName || defaultAccountName);
onActionComplete(true);
trackEvent({
category: MetaMetricsEventCategory.Accounts,
Expand Down
2 changes: 1 addition & 1 deletion ui/components/ui/editable-label/editable-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class EditableLabel extends Component {
return;
}

await this.props.onSubmit(this.state.value);
await this.props.onSubmit(this.state.value.trim());
this.setState({ isEditing: false });
}

Expand Down

0 comments on commit 9c6e8db

Please sign in to comment.