Skip to content

Commit 88e761d

Browse files
authored
Improve username validation message (#103271)
1 parent 87ab7d7 commit 88e761d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

client/me/account/main.jsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,16 @@ class Account extends Component {
813813
this.getUserSetting( 'user_login' ) === this.state.userLoginConfirm &&
814814
this.state.userLoginConfirm.length > 0;
815815

816+
const usernameValidationFailureMessage = this.getUsernameValidationFailureMessage();
817+
const isError = ! usernameMatch || usernameValidationFailureMessage;
818+
819+
let validationMessage = translate( 'Please re-enter your new username to confirm it.' );
820+
if ( usernameMatch ) {
821+
validationMessage = usernameValidationFailureMessage
822+
? usernameValidationFailureMessage
823+
: translate( 'Thanks for confirming your new username!' );
824+
}
825+
816826
return (
817827
<div className="account__username-form" key="usernameForm">
818828
<FormFieldset>
@@ -827,13 +837,9 @@ class Account extends Component {
827837
value={ this.state.userLoginConfirm ?? '' }
828838
onChange={ this.updateUserLoginConfirm }
829839
isValid={ usernameMatch }
830-
isError={ ! usernameMatch }
840+
isError={ isError }
831841
/>
832-
<FormInputValidation isError={ ! usernameMatch }>
833-
{ usernameMatch
834-
? translate( 'Thanks for confirming your new username!' )
835-
: translate( 'Please re-enter your new username to confirm it.' ) }
836-
</FormInputValidation>
842+
<FormInputValidation isError={ isError }>{ validationMessage }</FormInputValidation>
837843
</FormFieldset>
838844

839845
{ this.renderBlogActionFields() }

0 commit comments

Comments
 (0)