@@ -32,7 +32,7 @@ const Account = props => {
32
32
onSubmit = { handleSubmit }
33
33
validateOnBlur = { false }
34
34
>
35
- { ( { values, handleChange, errors, isSubmitting } ) => (
35
+ { ( { values, handleChange, errors, submitCount , isSubmitting } ) => (
36
36
< Form >
37
37
< Typography variant = "h6" gutterBottom >
38
38
Account Settings
@@ -42,7 +42,10 @@ const Account = props => {
42
42
< Grid item xs = { 12 } sm = { 12 } >
43
43
< FormControl
44
44
className = { classes . formControl }
45
- error = { errors . hasOwnProperty ( 'type' ) }
45
+ error = {
46
+ submitCount > 0 &&
47
+ errors . hasOwnProperty ( 'type' )
48
+ }
46
49
>
47
50
< InputLabel htmlFor = "type" >
48
51
Type{ ' ' }
@@ -68,11 +71,12 @@ const Account = props => {
68
71
< MenuItem value = "user" > User</ MenuItem >
69
72
</ Select >
70
73
71
- { errors . hasOwnProperty ( 'type' ) && (
72
- < FormHelperText >
73
- { errors . type }
74
- </ FormHelperText >
75
- ) }
74
+ { submitCount > 0 &&
75
+ errors . hasOwnProperty ( 'type' ) && (
76
+ < FormHelperText >
77
+ { errors . type }
78
+ </ FormHelperText >
79
+ ) }
76
80
</ FormControl >
77
81
</ Grid >
78
82
</ Grid >
@@ -81,7 +85,10 @@ const Account = props => {
81
85
< Grid item xs = { 12 } sm = { 6 } >
82
86
< FormControl
83
87
className = { classes . formControl }
84
- error = { errors . hasOwnProperty ( 'email' ) }
88
+ error = {
89
+ submitCount > 0 &&
90
+ errors . hasOwnProperty ( 'email' )
91
+ }
85
92
>
86
93
< InputLabel htmlFor = "email" >
87
94
Email{ ' ' }
@@ -95,18 +102,23 @@ const Account = props => {
95
102
onChange = { handleChange }
96
103
fullWidth
97
104
/>
98
- { errors . hasOwnProperty ( 'email' ) && (
99
- < FormHelperText >
100
- { errors . email }
101
- </ FormHelperText >
102
- ) }
105
+
106
+ { submitCount > 0 &&
107
+ errors . hasOwnProperty ( 'email' ) && (
108
+ < FormHelperText >
109
+ { errors . email }
110
+ </ FormHelperText >
111
+ ) }
103
112
</ FormControl >
104
113
</ Grid >
105
114
106
115
< Grid item xs = { 12 } sm = { 6 } >
107
116
< FormControl
108
117
className = { classes . formControl }
109
- error = { errors . hasOwnProperty ( 'username' ) }
118
+ error = {
119
+ submitCount > 0 &&
120
+ errors . hasOwnProperty ( 'username' )
121
+ }
110
122
>
111
123
< InputLabel htmlFor = "username" >
112
124
Username
@@ -119,11 +131,13 @@ const Account = props => {
119
131
onChange = { handleChange }
120
132
fullWidth
121
133
/>
122
- { errors . hasOwnProperty ( 'username' ) && (
123
- < FormHelperText >
124
- { errors . username }
125
- </ FormHelperText >
126
- ) }
134
+
135
+ { submitCount > 0 &&
136
+ errors . hasOwnProperty ( 'username' ) && (
137
+ < FormHelperText >
138
+ { errors . username }
139
+ </ FormHelperText >
140
+ ) }
127
141
</ FormControl >
128
142
</ Grid >
129
143
</ Grid >
@@ -145,7 +159,8 @@ const Account = props => {
145
159
color = "primary"
146
160
disabled = {
147
161
( errors &&
148
- Object . keys ( errors ) . length > 0 ) ||
162
+ Object . keys ( errors ) . length > 0 &&
163
+ submitCount > 0 ) ||
149
164
isSubmitting
150
165
}
151
166
>
0 commit comments