aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-08-29 00:22:27 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-08-29 00:22:27 +0300
commitae005b8444aacc4071512f38031043156b6854c4 (patch)
treef57d85090b3a89fb2e28f9ae869b9b206a31ac3e /src
parentceff44e622a07c5c17484e0222c78785fe12e6d2 (diff)
downloadwhich-ui-ae005b8444aacc4071512f38031043156b6854c4.tar.gz
hide error state onFocue input
Diffstat (limited to 'src')
-rw-r--r--src/containers/Registration/Registration.tsx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/containers/Registration/Registration.tsx b/src/containers/Registration/Registration.tsx
index 709d04e..e7c8874 100644
--- a/src/containers/Registration/Registration.tsx
+++ b/src/containers/Registration/Registration.tsx
@@ -44,16 +44,16 @@ const useStyles = makeStyles(theme => ({
}));
interface ErrorStates {
- username: boolean;
- email: boolean;
- password: boolean;
+ username: boolean | undefined;
+ email: boolean | undefined;
+ password: boolean | undefined;
}
const Registration: React.FC = () => {
const [errors, setErrors] = useState<ErrorStates>({
- username: false,
- email: false,
- password: false
+ username: undefined,
+ email: undefined,
+ password: undefined
});
const [showPassword, setShowPassword] = useState<boolean>(false);
@@ -112,6 +112,13 @@ const Registration: React.FC = () => {
e.target.value = e.target.value.toString().toLowerCase();
};
+ const handleFocus = (value: string) => () => {
+ setErrors({
+ ...errors,
+ [value]: undefined
+ });
+ };
+
return (
<>
<div className={classes.formHeader}>Sign Up</div>
@@ -124,6 +131,7 @@ const Registration: React.FC = () => {
required
onBlur={handleUsernameChange}
onInput={handleToLowerCase}
+ onFocus={handleFocus('username')}
/>
<TextField
inputRef={emailRef}
@@ -131,6 +139,7 @@ const Registration: React.FC = () => {
error={errors.email}
helperText={errors.email && 'Invalid email address'}
onBlur={handleEmailChange}
+ onFocus={handleFocus('email')}
/>
<TextField
inputRef={passwordRef}
@@ -140,6 +149,7 @@ const Registration: React.FC = () => {
helperText={errors.password && 'Should be at least 6 characters'}
type={showPassword ? 'text' : 'password'}
onBlur={handlePasswordChange}
+ onFocus={handleFocus('password')}
InputProps={{
endAdornment: (
<InputAdornment position="end">