From e082a210e9a454c31a5a401ef7fb998c9608ceb9 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 16:26:16 +0000 Subject: [PATCH 1/4] Remove jQuery from the "quick submit" handler - Switched to plain JavaScript - Tested the quick submit functionality and it works as before Signed-off-by: Yarden Shoham --- web_src/js/features/comp/QuickSubmit.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js index 2587375a717d6..c8ba688024aaf 100644 --- a/web_src/js/features/comp/QuickSubmit.js +++ b/web_src/js/features/comp/QuickSubmit.js @@ -1,5 +1,3 @@ -import $ from 'jquery'; - export function handleGlobalEnterQuickSubmit(target) { const form = target.closest('form'); if (form) { @@ -15,7 +13,7 @@ export function handleGlobalEnterQuickSubmit(target) { // here use the event to trigger the submit event (instead of calling `submit()` method directly) // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog - $(form).trigger('submit'); + form.dispatchEvent(new Event('submit', {bubbles: true, cancelable: true})); } else { // if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request. // the 'ce-' prefix means this is a CustomEvent From a97d30a64ff3bc63190dfb04fef8b0ae8cba9a49 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 17:06:26 +0000 Subject: [PATCH 2/4] Use `SubmitEvent` --- web_src/js/features/comp/QuickSubmit.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js index c8ba688024aaf..e6d7080bcf1a6 100644 --- a/web_src/js/features/comp/QuickSubmit.js +++ b/web_src/js/features/comp/QuickSubmit.js @@ -6,14 +6,9 @@ export function handleGlobalEnterQuickSubmit(target) { return; } - if (form.classList.contains('form-fetch-action')) { - form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true})); - return; - } - // here use the event to trigger the submit event (instead of calling `submit()` method directly) // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog - form.dispatchEvent(new Event('submit', {bubbles: true, cancelable: true})); + form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true})); } else { // if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request. // the 'ce-' prefix means this is a CustomEvent From cf8d365bc6a6b6410009cc3bc887d28c5a71a578 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 17:16:16 +0000 Subject: [PATCH 3/4] Remove defaults --- web_src/js/features/comp/QuickSubmit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js index e6d7080bcf1a6..a9c1faac0df7a 100644 --- a/web_src/js/features/comp/QuickSubmit.js +++ b/web_src/js/features/comp/QuickSubmit.js @@ -8,7 +8,7 @@ export function handleGlobalEnterQuickSubmit(target) { // here use the event to trigger the submit event (instead of calling `submit()` method directly) // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog - form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true})); + form.dispatchEvent(new SubmitEvent('submit')); } else { // if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request. // the 'ce-' prefix means this is a CustomEvent From 01ee4c23d2355c7133a094a56f841a0e216e8783 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Fri, 16 Feb 2024 17:19:13 +0000 Subject: [PATCH 4/4] Revert "Remove defaults" This reverts commit cf8d365bc6a6b6410009cc3bc887d28c5a71a578. --- web_src/js/features/comp/QuickSubmit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js index a9c1faac0df7a..e6d7080bcf1a6 100644 --- a/web_src/js/features/comp/QuickSubmit.js +++ b/web_src/js/features/comp/QuickSubmit.js @@ -8,7 +8,7 @@ export function handleGlobalEnterQuickSubmit(target) { // here use the event to trigger the submit event (instead of calling `submit()` method directly) // otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog - form.dispatchEvent(new SubmitEvent('submit')); + form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true})); } else { // if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request. // the 'ce-' prefix means this is a CustomEvent