MDL-86455 forms: disable all modal submit buttons on button click

To provide visual feedback and prevent multiple clicks
on no-submit buttons, all submit buttons within a modal
form will be disabled once any of them is clicked.
This commit is contained in:
Yerai Rodríguez
2025-10-16 16:26:18 +02:00
parent 25614d858b
commit 2145fd918d
3 changed files with 11 additions and 5 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+9 -3
View File
@@ -328,9 +328,13 @@ export default class ModalForm {
formData = formData + '&' + encodeURIComponent(button.getAttribute('name')) + '=' +
encodeURIComponent(button.getAttribute('value'));
this.disableButtons();
const bodyContent = this.getBody(formData);
this.modal.setBodyContent(bodyContent);
bodyContent.catch(Notification.exception);
bodyContent
.then(() => this.enableButtons())
.catch(Notification.exception);
}
/**
@@ -358,14 +362,16 @@ export default class ModalForm {
* Disable buttons during form submission
*/
disableButtons() {
this.modal.getFooter().find('[data-action]').attr('disabled', true);
this.modal.getModal()[0].querySelectorAll('input[type="submit"], [data-action]')
.forEach(el => el.setAttribute('disabled', true));
}
/**
* Enable buttons after form submission (on validation error)
*/
enableButtons() {
this.modal.getFooter().find('[data-action]').removeAttr('disabled');
this.modal.getModal()[0].querySelectorAll('input[type="submit"], [data-action]')
.forEach(el => el.removeAttribute('disabled'));
}
/**