fix: do not pass undefined data through buildStateFromSchema for tab fields
This commit is contained in:
@@ -517,13 +517,13 @@ export const addFieldStatePromise = async (args: AddFieldStatePromiseArgs): Prom
|
||||
state,
|
||||
})
|
||||
} else if (field.type === 'tabs') {
|
||||
const promises = field.tabs.map((tab) =>
|
||||
iterateFields({
|
||||
const promises = field.tabs.map((tab) => {
|
||||
return iterateFields({
|
||||
id,
|
||||
// passthrough parent functionality
|
||||
addErrorPathToParent: addErrorPathToParentArg,
|
||||
anyParentLocalized: tab.localized || anyParentLocalized,
|
||||
data: tabHasName(tab) ? data?.[tab.name] : data,
|
||||
data: tabHasName(tab) ? data?.[tab.name] || {} : data,
|
||||
fields: tab.fields,
|
||||
filter,
|
||||
forceFullValue,
|
||||
@@ -538,8 +538,8 @@ export const addFieldStatePromise = async (args: AddFieldStatePromiseArgs): Prom
|
||||
skipConditionChecks,
|
||||
skipValidation,
|
||||
state,
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
await Promise.all(promises)
|
||||
}
|
||||
|
||||
@@ -65,6 +65,13 @@ export const useField = <T,>(options: Options): FieldType<T> => {
|
||||
(e, disableModifyingForm = false) => {
|
||||
const val = e && e.target ? e.target.value : e
|
||||
|
||||
dispatchField({
|
||||
type: 'UPDATE',
|
||||
disableFormData: disableFormData || (hasRows && val > 0),
|
||||
path,
|
||||
value: val,
|
||||
})
|
||||
|
||||
if (!disableModifyingForm) {
|
||||
if (typeof setModified === 'function') {
|
||||
// Only update setModified to true if the form is not already set to modified. Otherwise the following could happen:
|
||||
@@ -89,13 +96,6 @@ export const useField = <T,>(options: Options): FieldType<T> => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispatchField({
|
||||
type: 'UPDATE',
|
||||
disableFormData: disableFormData || (hasRows && val > 0),
|
||||
path,
|
||||
value: val,
|
||||
})
|
||||
},
|
||||
[setModified, path, dispatchField, disableFormData, hasRows, modified],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user