BUGFIX: values resetted if error

This commit is contained in:
Simon Martens
2026-01-23 20:21:32 +01:00
parent 0beb5a2c79
commit ad02de8807
11 changed files with 465 additions and 317 deletions

View File

@@ -644,6 +644,48 @@ function InitStickyActionBars() {
document.addEventListener("htmx:afterSwap", update);
}
function InitTimedMessages() {
const duration = 2000;
const hide = (el) => {
if (!el || el.classList.contains("hidden") || el.classList.contains("is-hidden")) {
return;
}
requestAnimationFrame(() => {
el.classList.add("is-hiding");
});
setTimeout(() => {
el.classList.add("is-hidden");
el.classList.remove("is-hiding");
delete el.dataset.autohideScheduled;
}, 320);
};
const schedule = (root) => {
const scope = root || document;
scope.querySelectorAll("[data-autohide='true']").forEach((el) => {
if (el.dataset.autohideScheduled === "true") {
return;
}
el.dataset.autohideScheduled = "true";
setTimeout(() => hide(el), duration);
});
};
schedule(document);
document.addEventListener("htmx:afterSwap", (event) => {
schedule(event.target);
});
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
for (const node of mutation.addedNodes) {
if (node.nodeType !== Node.ELEMENT_NODE) continue;
schedule(node);
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
}
document.addEventListener("keydown", (event) => {
if (event.key !== "Enter") {
return;
@@ -664,7 +706,9 @@ window.PathPlusQuery = PathPlusQuery;
window.HookupRBChange = HookupRBChange;
window.FormLoad = FormLoad;
window.TextareaAutoResize = TextareaAutoResize;
window.InitTimedMessages = InitTimedMessages;
InitGlobalHtmxNotice();
InitStickyActionBars();
InitTimedMessages();
export { FilterList, ScrollButton, AbbreviationTooltips, MultiSelectSimple, MultiSelectRole, ToolTip, PopupImage, TabList, FilterPill, ImageReel, IntLink, ItemsEditor, SingleSelectRemote, AlmanachEditPage, RelationsEditor, EditPage, FabMenu, LookupField };