@@ -52,6 +52,11 @@ export function CollectionDetailsForm({
52
52
submitCount
53
53
} = useFormex < EntityCollection > ( ) ;
54
54
55
+ console . log ( {
56
+ touched,
57
+ errors,
58
+ } )
59
+
55
60
const [ iconDialogOpen , setIconDialogOpen ] = useState ( false ) ;
56
61
const [ advancedPanelExpanded , setAdvancedPanelExpanded ] = useState ( false ) ;
57
62
@@ -70,7 +75,7 @@ export function CollectionDetailsForm({
70
75
71
76
const singularNameTouched = getIn ( touched , "singularName" ) ;
72
77
if ( ! singularNameTouched && isNewCollection && name ) {
73
- setFieldValue ( "singularName" , singular ( name ) )
78
+ setFieldValue ( "singularName" , singular ( name ) ) ;
74
79
}
75
80
76
81
} ;
@@ -107,6 +112,8 @@ export function CollectionDetailsForm({
107
112
customIdValue = "optional" ;
108
113
}
109
114
}
115
+
116
+ const showErrors = submitCount > 0 ;
110
117
return (
111
118
< div className = { "overflow-auto my-auto" } >
112
119
< Container maxWidth = { "4xl" } className = { "flex flex-col gap-4 p-8 m-auto" } >
@@ -141,7 +148,7 @@ export function CollectionDetailsForm({
141
148
onChange = { ( e : any ) => updateName ( e . target . value ) }
142
149
label = { "Name" }
143
150
required
144
- error = { touched . name && Boolean ( errors . name ) } />
151
+ error = { showErrors && Boolean ( errors . name ) } />
145
152
< FieldHelperView error = { touched . name && Boolean ( errors . name ) } >
146
153
{ touched . name && Boolean ( errors . name ) ? errors . name : "Name of in this collection, usually a plural name (e.g. Products)" }
147
154
</ FieldHelperView >
@@ -153,7 +160,7 @@ export function CollectionDetailsForm({
153
160
label = { "Path" }
154
161
disabled = { ! isNewCollection }
155
162
required
156
- error = { touched . path && Boolean ( errors . path ) } />
163
+ error = { showErrors && Boolean ( errors . path ) } />
157
164
158
165
< FieldHelperView error = { touched . path && Boolean ( errors . path ) } >
159
166
{ touched . path && Boolean ( errors . path )
@@ -165,7 +172,7 @@ export function CollectionDetailsForm({
165
172
166
173
{ ! isSubcollection && < div className = { "col-span-12 sm:col-span-4 relative" } >
167
174
168
- < TextField error = { touched . group && Boolean ( errors . group ) }
175
+ < TextField error = { showErrors && Boolean ( errors . group ) }
169
176
disabled = { isSubmitting }
170
177
value = { values . group ?? "" }
171
178
autoComplete = "off"
@@ -191,7 +198,7 @@ export function CollectionDetailsForm({
191
198
} ) }
192
199
</ Autocomplete >
193
200
< FieldHelperView >
194
- { touched . group && Boolean ( errors . group ) ? errors . group : "Group of the collection" }
201
+ { showErrors && Boolean ( errors . group ) ? errors . group : "Group of the collection" }
195
202
</ FieldHelperView >
196
203
</ div > }
197
204
@@ -215,15 +222,15 @@ export function CollectionDetailsForm({
215
222
as = { DebouncedTextField }
216
223
disabled = { ! isNewCollection }
217
224
label = { "Collection id" }
218
- error = { touched . id && Boolean ( errors . id ) } />
225
+ error = { showErrors && Boolean ( errors . id ) } />
219
226
< FieldHelperView error = { touched . id && Boolean ( errors . id ) } >
220
227
{ touched . id && Boolean ( errors . id ) ? errors . id : "This id identifies this collection" }
221
228
</ FieldHelperView >
222
229
</ div >
223
230
224
231
< div className = { "col-span-12" } >
225
232
< TextField
226
- error = { touched . singularName && Boolean ( errors . singularName ) }
233
+ error = { showErrors && Boolean ( errors . singularName ) }
227
234
id = { "singularName" }
228
235
aria-describedby = { "singularName-helper" }
229
236
onChange = { ( e ) => {
@@ -232,13 +239,13 @@ export function CollectionDetailsForm({
232
239
} }
233
240
value = { values . singularName ?? "" }
234
241
label = { "Singular name" } />
235
- < FieldHelperView error = { touched . singularName && Boolean ( errors . singularName ) } >
236
- { touched . singularName && Boolean ( errors . singularName ) ? errors . singularName : "Optionally define a singular name for your entities" }
242
+ < FieldHelperView error = { showErrors && Boolean ( errors . singularName ) } >
243
+ { showErrors && Boolean ( errors . singularName ) ? errors . singularName : "Optionally define a singular name for your entities" }
237
244
</ FieldHelperView >
238
245
</ div >
239
246
< div className = { "col-span-12" } >
240
247
< TextField
241
- error = { touched . description && Boolean ( errors . description ) }
248
+ error = { showErrors && Boolean ( errors . description ) }
242
249
id = "description"
243
250
value = { values . description ?? "" }
244
251
onChange = { handleChange }
@@ -247,8 +254,8 @@ export function CollectionDetailsForm({
247
254
aria-describedby = "description-helper-text"
248
255
label = "Description"
249
256
/>
250
- < FieldHelperView error = { touched . description && Boolean ( errors . description ) } >
251
- { touched . description && Boolean ( errors . description ) ? errors . description : "Description of the collection, you can use markdown" }
257
+ < FieldHelperView error = { showErrors && Boolean ( errors . description ) } >
258
+ { showErrors && Boolean ( errors . description ) ? errors . description : "Description of the collection, you can use markdown" }
252
259
</ FieldHelperView >
253
260
</ div >
254
261
0 commit comments