1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-26 18:21:01 +00:00

fix(js): handle multiple buttons in a single form when showing loading state

This commit is contained in:
Frédéric Guillot 2025-08-01 20:50:00 -07:00
parent 1ec90e34f5
commit 7a25cf5037
2 changed files with 13 additions and 7 deletions

View file

@ -140,15 +140,21 @@ function onClickMainMenuListItem(event) {
}
}
// Change the button label when the page is loading.
function handleSubmitButtons() {
/**
* This function changes the button label to the loading state and disables the button.
*
* @returns {void}
*/
function disableSubmitButtonsOnFormSubmit() {
document.querySelectorAll("form").forEach((element) => {
element.onsubmit = () => {
const button = element.querySelector("button");
if (button) {
button.textContent = button.dataset.labelLoading;
const buttons = element.querySelectorAll("button[type=submit]");
buttons.forEach((button) => {
if (button.dataset.labelLoading) {
button.textContent = button.dataset.labelLoading;
}
button.disabled = true;
}
});
};
});
}