From 5c467b2188d909eef8e8abcefdeabd59cfcb0fcc Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Thu, 15 Oct 2020 15:42:49 -0300 Subject: [PATCH] =?UTF-8?q?Disable=20=E2=80=98dirty=20form=E2=80=99=20fix?= =?UTF-8?q?=20in=20onboarding=20JS=20as=20it=20conflicts=20with=20other=20?= =?UTF-8?q?handlers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ppcp-onboarding/assets/js/onboarding.js | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-onboarding/assets/js/onboarding.js b/modules/ppcp-onboarding/assets/js/onboarding.js index 3b67c10d6..15d2abc05 100644 --- a/modules/ppcp-onboarding/assets/js/onboarding.js +++ b/modules/ppcp-onboarding/assets/js/onboarding.js @@ -173,12 +173,29 @@ const disconnect = (event) => { } ); - document.querySelectorAll('#mainform input[type="checkbox"]').forEach( - (checkbox) => { - checkbox.addEventListener('click', checkBoxOnClick); + // Prevent a possibly dirty form arising from this particular checkbox. + sandboxSwitchElement.addEventListener( + 'click', + (event) => { + const value = event.target.checked; + + toggleSandboxProduction( ! value ); + + event.preventDefault(); + event.stopPropagation(); + setTimeout( () => { + event.target.checked = value; + }, 1 + ); } ); + // document.querySelectorAll('#mainform input[type="checkbox"]').forEach( + // (checkbox) => { + // checkbox.addEventListener('click', checkBoxOnClick); + // } + // ); + document.querySelectorAll('#field-sandbox_toggle_manual_input button, #field-production_toggle_manual_input button').forEach( (button) => { button.addEventListener( @@ -192,4 +209,4 @@ const disconnect = (event) => { } ) -})(); \ No newline at end of file +})();