fix: sometimes forms didn't submit
Massimo Melina committed
Feb 2, 2023 at 16:46 UTC
2d3991f29544d5769660eccf0098d9d441e98439
1 file changed
+6
-3
mui-grid-form/index.ts
+6
-3
@@ -159,8 +159,11 @@ export function Form<Values extends Dict>({
159
},
160
} as Partial<FieldProps<any>>)
161
if (errMsg) // special rendering when we have both error and helperText. "hr" would be nice but issues a warning because contained in a <p>
162
- field.helperText = field.helperText ? h(Fragment, {}, h('span', { style: { borderBottom: '1px solid' } }, errMsg), h('br'), field.helperText)
163
- : errMsg
162
+ field.helperText = !field.helperText ? errMsg
163
+ : h(Fragment, {},
164
+ h('span', { style: { borderBottom: '1px solid' } }, errMsg),
165
+ h('br'), field.helperText
166
+ )
167
if (field.label === undefined)
168
field.label = labelFromKey(k)
169
_.defaults(field, defaults?.(whole))
@@ -206,7 +209,7 @@ export function Form<Values extends Dict>({
209
if (phase !== Phase.Idle) return
210
validateUpTo.current = k
211
setTimeout(() => // starting validation immediately will lose clicks on the saveBtn, so delay just a bit
209
- setPhase(Phase.WaitValues))
212
+ setPhase(cur => cur === Phase.Idle ? Phase.WaitValues : cur)) // don't interfere with ongoing process
213
}
214
215
async function phaseChange() {