Disable save button while submitting form in settings (#5352)
as per title
This commit is contained in:
@ -86,15 +86,19 @@ export const SettingsObjectFieldEdit = () => {
|
||||
|
||||
if (!activeObjectMetadataItem || !activeMetadataField) return null;
|
||||
|
||||
const canSave = formConfig.formState.isValid && formConfig.formState.isDirty;
|
||||
const canSave =
|
||||
formConfig.formState.isValid &&
|
||||
formConfig.formState.isDirty &&
|
||||
!formConfig.formState.isSubmitting;
|
||||
|
||||
const isLabelIdentifier = isLabelIdentifierField({
|
||||
fieldMetadataItem: activeMetadataField,
|
||||
objectMetadataItem: activeObjectMetadataItem,
|
||||
});
|
||||
|
||||
const handleSave = async () => {
|
||||
const formValues = formConfig.getValues();
|
||||
const handleSave = async (
|
||||
formValues: SettingsDataModelFieldEditFormValues,
|
||||
) => {
|
||||
const { dirtyFields } = formConfig.formState;
|
||||
|
||||
try {
|
||||
@ -166,7 +170,7 @@ export const SettingsObjectFieldEdit = () => {
|
||||
<SaveAndCancelButtons
|
||||
isSaveDisabled={!canSave}
|
||||
onCancel={() => navigate(`/settings/objects/${objectSlug}`)}
|
||||
onSave={handleSave}
|
||||
onSave={formConfig.handleSubmit(handleSave)}
|
||||
/>
|
||||
)}
|
||||
</SettingsHeaderContainer>
|
||||
|
||||
Reference in New Issue
Block a user