From e8993829a067b8fd92c19b9a0c4638b6e3df2c38 Mon Sep 17 00:00:00 2001 From: Awais Ansari <79941147+awais-ansari@users.noreply.github.com> Date: Fri, 13 May 2022 15:27:03 +0500 Subject: [PATCH] fix: requestSubmit() is not a function in safari (#301) --- .../app-config-form/AppConfigFormSaveButton.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages-and-resources/discussions/app-config-form/AppConfigFormSaveButton.jsx b/src/pages-and-resources/discussions/app-config-form/AppConfigFormSaveButton.jsx index ba03d74c9..4ea9225ab 100644 --- a/src/pages-and-resources/discussions/app-config-form/AppConfigFormSaveButton.jsx +++ b/src/pages-and-resources/discussions/app-config-form/AppConfigFormSaveButton.jsx @@ -15,7 +15,7 @@ function AppConfigFormSaveButton({ intl, labelText }) { const { selectedAppId } = useSelector((state) => state.discussions); const app = useModel('apps', selectedAppId); - const canSubmit = getAuthenticatedUser().administrator || !app.adminOnlyConfig; + const canSubmit = getAuthenticatedUser().administrator || !app?.adminOnlyConfig; const { formRef } = useContext(AppConfigFormContext); @@ -23,7 +23,12 @@ function AppConfigFormSaveButton({ intl, labelText }) { // This causes the form to be submitted from a button outside the form. const handleSave = useCallback(() => { - formRef.current.requestSubmit(); + // https://developer.mozilla.org/en-US/docs/Web/API/Event/Event + // cancelable: (optional) a Boolean indicating whether the event can be canceled. The default is false. + // cancelable: true cancels the untrusted event and safari, chrome cancel the untrusted event by default + formRef.current.dispatchEvent(new Event('submit', { + cancelable: true, + })); }, [formRef]); return (