mirror of
https://github.com/miniflux/v2.git
synced 2025-08-11 17:51:01 +00:00
fix(js): handle multiple buttons in a single form when showing loading state
This commit is contained in:
parent
1ec90e34f5
commit
7a25cf5037
2 changed files with 13 additions and 7 deletions
|
@ -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) => {
|
document.querySelectorAll("form").forEach((element) => {
|
||||||
element.onsubmit = () => {
|
element.onsubmit = () => {
|
||||||
const button = element.querySelector("button");
|
const buttons = element.querySelectorAll("button[type=submit]");
|
||||||
if (button) {
|
buttons.forEach((button) => {
|
||||||
|
if (button.dataset.labelLoading) {
|
||||||
button.textContent = button.dataset.labelLoading;
|
button.textContent = button.dataset.labelLoading;
|
||||||
button.disabled = true;
|
|
||||||
}
|
}
|
||||||
|
button.disabled = true;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
2
internal/ui/static/js/bootstrap.js
vendored
2
internal/ui/static/js/bootstrap.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
handleSubmitButtons();
|
disableSubmitButtonsOnFormSubmit();
|
||||||
|
|
||||||
if (!document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
|
if (!document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
|
||||||
const keyboardHandler = new KeyboardHandler();
|
const keyboardHandler = new KeyboardHandler();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue