Webatrice: tech debt (#4560)

* turn autocomplete off by default on inputs

* trim input fields onSubmit

* move trim to form submit

* cleanup

* remove dead code

* protect trim against null values

* make password optional on Login for servers that allow unregisted logins

* cleanup

Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
Jeremy Letto 2022-02-06 10:41:02 -06:00 committed by GitHub
parent 6928a2bd98
commit bf08a04cda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 53 additions and 112 deletions

View file

@ -47,9 +47,14 @@ const RegisterForm = ({ onSubmit }: RegisterFormProps) => {
setUserNameError(error);
}, ServerTypes.REGISTRATION_USERNAME_ERROR);
const handleOnSubmit = form => {
const handleOnSubmit = ({ userName, email, realName, ...values }) => {
setError(null);
onSubmit(form);
userName = userName?.trim();
email = email?.trim();
realName = realName?.trim();
onSubmit({ userName, email, realName, ...values });
}
const validate = values => {
@ -100,10 +105,10 @@ const RegisterForm = ({ onSubmit }: RegisterFormProps) => {
return (
<>
<form className="RegisterForm" onSubmit={handleSubmit} autoComplete="off">
<form className="RegisterForm" onSubmit={handleSubmit}>
<div className="RegisterForm-column">
<div className="RegisterForm-item">
<Field label="Player Name" name="userName" component={InputField} />
<Field label="Player Name" name="userName" component={InputField} autoComplete="username" />
<OnChange name="userName">{onUserNameChange}</OnChange>
</div>
<div className="RegisterForm-item">
@ -126,7 +131,7 @@ const RegisterForm = ({ onSubmit }: RegisterFormProps) => {
</div>
<div className="RegisterForm-column" >
<div className="RegisterForm-item">
<Field label="Real Name" name="realName" component={InputField} autoComplete='off' />
<Field label="Real Name" name="realName" component={InputField} />
</div>
<div className="RegisterForm-item">
<Field label="Email" name="email" type="email" component={InputField} />