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:
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user