From f5b6ef39dfccba0e7f3a3776ae2654f434f7a43b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 12 Jan 2023 09:53:45 +0100 Subject: [PATCH] Merge pull request #4976 from Icinga/do-not-disable-all-inputs-on-form-submit js: Only disable submit buttons on form submit (cherry picked from commit 96179182e413b5285ad8be00e7124fd278e300c3) --- public/js/icinga/behavior/modal.js | 6 ++++-- public/js/icinga/loader.js | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/js/icinga/behavior/modal.js b/public/js/icinga/behavior/modal.js index 7e940b566..0083f769b 100644 --- a/public/js/icinga/behavior/modal.js +++ b/public/js/icinga/behavior/modal.js @@ -119,8 +119,10 @@ } }); - // otherwise the form is submitted several times by clicking the "Submit" button several times - $form.find('input:not(:disabled)').prop('disabled', true); + if (typeof $autoSubmittedBy === 'undefined') { + // otherwise the form is submitted several times by clicking the "Submit" button several times + $form.find('input[type=submit],button[type=submit],button:not([type])').prop('disabled', true); + } event.stopPropagation(); event.preventDefault(); diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 8d3ecd182..d298cc5d8 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -129,8 +129,11 @@ // Disable all form controls to prevent resubmission except for our search input // Note that disabled form inputs will not be enabled via JavaScript again - if (! $form.is('[role="search"]') && $target.attr('id') === $form.closest('.container').attr('id')) { - $form.find('input:not(:disabled)').prop('disabled', true); + if (! $autoSubmittedBy + && ! $form.is('[role="search"]') + && $target.attr('id') === $form.closest('.container').attr('id') + ) { + $form.find('input[type=submit],button[type=submit],button:not([type])').prop('disabled', true); } // Show a spinner depending on how the form is being submitted