From 2381de0722eecdb844aca37f9a9727440ed76f42 Mon Sep 17 00:00:00 2001 From: karanh37 Date: Thu, 25 Sep 2025 11:40:35 +0530 Subject: [PATCH] Revert "Reset form on submit and cancel" This reverts commit e2a19cfd1005d0d967530931287c0a125595eef7. --- .../AddDomainForm/AddDomainForm.component.tsx | 2 +- .../common/atoms/drawer/useFormDrawer.tsx | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx index b40fb0eb01a..0e938dcf516 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Domain/AddDomainForm/AddDomainForm.component.tsx @@ -303,7 +303,7 @@ const AddDomainForm = ({ delete (data as CreateDomain & { domains?: unknown }).domains; } - onSubmit(data); + onSubmit(data).then(() => form.resetFields()); }; return ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useFormDrawer.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useFormDrawer.tsx index 872b59ba461..76c44a0463a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useFormDrawer.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/atoms/drawer/useFormDrawer.tsx @@ -24,7 +24,6 @@ export interface FormDrawerConfig form: ReactNode; onSubmit: (data: T) => Promise | void; onCancel?: () => void; - onReset?: () => void; submitLabel?: string; cancelLabel?: string; loading?: boolean; @@ -85,7 +84,6 @@ export const useFormDrawer = (config: FormDrawerConfig) => { form, onSubmit, onCancel, - onReset, submitLabel = t('label.save'), cancelLabel = t('label.cancel'), loading = false, @@ -116,10 +114,7 @@ export const useFormDrawer = (config: FormDrawerConfig) => { label: cancelLabel, variant: 'text', testId: cancelTestId, - onClick: () => { - closeRef.current(); - onReset?.(); // Reset form on cancel - }, + onClick: () => closeRef.current(), }, primaryButton: { label: submitLabel, @@ -136,7 +131,6 @@ export const useFormDrawer = (config: FormDrawerConfig) => { // Form submission error handled by caller } finally { setIsSubmitting(false); - onReset?.(); // Reset form on submit } }, }, @@ -179,11 +173,7 @@ export const useFormDrawer = (config: FormDrawerConfig) => { */ export const useFormDrawerWithRef = ( config: FormDrawerConfig & { - formRef?: { - submit: () => void; - validateFields?: () => Promise; - resetFields: () => void; - }; + formRef?: { submit: () => void; validateFields?: () => Promise }; } ) => { const { formRef, onSubmit, ...restConfig } = config; @@ -208,7 +198,6 @@ export const useFormDrawerWithRef = ( const drawer = useFormDrawer({ ...restConfig, onSubmit: handleSubmit, - onReset: formRef?.resetFields, }); const submitForm = useCallback(() => {