From d5f5614f4bbb16346bc3e2369c09f49aa1305d7f Mon Sep 17 00:00:00 2001 From: Kiran Ashok Date: Fri, 24 May 2024 20:34:42 +0530 Subject: [PATCH] fix : form csa for onsubmit not getting triggered (#9862) --- frontend/src/Editor/Components/Form/Form.jsx | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/frontend/src/Editor/Components/Form/Form.jsx b/frontend/src/Editor/Components/Form/Form.jsx index 6e3a11b114..fd86c8c61a 100644 --- a/frontend/src/Editor/Components/Form/Form.jsx +++ b/frontend/src/Editor/Components/Form/Form.jsx @@ -66,19 +66,16 @@ export const Form = function Form(props) { const mounted = useMounted(); useEffect(() => { - const exposedVariables = { - resetForm: async function () { - resetComponent(); - }, - submitForm: async function () { - if (isValid) { - onEvent('onSubmit', formEvents).then(() => resetComponent()); - } else { - fireEvent('onInvalid'); - } - }, - }; - setExposedVariables(exposedVariables); + setExposedVariable('resetForm', async function () { + resetComponent(); + }); + setExposedVariable('submitForm', async function () { + if (isValid) { + onEvent('onSubmit', formEvents).then(() => resetComponent()); + } else { + fireEvent('onInvalid'); + } + }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []);