File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -140,15 +140,21 @@ function onClickMainMenuListItem(event) {
140140 }
141141}
142142
143- // Change the button label when the page is loading.
144- function handleSubmitButtons ( ) {
143+ /**
144+ * This function changes the button label to the loading state and disables the button.
145+ *
146+ * @returns {void }
147+ */
148+ function disableSubmitButtonsOnFormSubmit ( ) {
145149 document . querySelectorAll ( "form" ) . forEach ( ( element ) => {
146150 element . onsubmit = ( ) => {
147- const button = element . querySelector ( "button" ) ;
148- if ( button ) {
149- button . textContent = button . dataset . labelLoading ;
151+ const buttons = element . querySelectorAll ( "button[type=submit]" ) ;
152+ buttons . forEach ( ( button ) => {
153+ if ( button . dataset . labelLoading ) {
154+ button . textContent = button . dataset . labelLoading ;
155+ }
150156 button . disabled = true ;
151- }
157+ } ) ;
152158 } ;
153159 } ) ;
154160}
Original file line number Diff line number Diff line change 11document . addEventListener ( "DOMContentLoaded" , ( ) => {
2- handleSubmitButtons ( ) ;
2+ disableSubmitButtonsOnFormSubmit ( ) ;
33
44 if ( ! document . querySelector ( "body[data-disable-keyboard-shortcuts=true]" ) ) {
55 const keyboardHandler = new KeyboardHandler ( ) ;
You can’t perform that action at this time.
0 commit comments