Skip to content
Snippets Groups Projects

Draft: Issue #3144382: When page is loaded via back button (persisted) re-enable disabled form submit button

Open Draft: Issue #3144382: When page is loaded via back button (persisted) re-enable disabled form submit button
Open rhovland requested to merge issue/drupal-3144382:3144382-prevention-of-multiple into 11.x
+ 14
2
@@ -22,7 +22,7 @@
* @event formFragmentLinkClickOrHashChange
*/
(function ($, Drupal, debounce) {
(function ($, window, Drupal, debounce) {
/**
* Retrieves the summary for the first element.
*
@@ -141,6 +141,18 @@
'form:not([method~="GET"])',
onFormSubmit,
);
// Binds a listener to clear stored form values from formSingleSubmit() when
// page is loaded from back/forward cache. This allows the form submission
// button to be used again instead of remaining disabled.
// Checking persisted does not work with jQuery on().
window.addEventListener('pageshow', (event) => {
if (event.persisted) {
$('form:not([method~="GET"])').removeAttr(
'data-drupal-form-submit-last',
);
}
});
},
};
@@ -331,4 +343,4 @@
'a[href*="#"]',
debouncedHandleFragmentLinkClickOrHashChange,
);
})(jQuery, Drupal, Drupal.debounce);
})(jQuery, window, Drupal, Drupal.debounce);
Loading