Fix ingredient modal closing recipe editor
Ingredient modal's onSubmit returned undefined → showModal treated it as success → closeModal + renderScreen → killed the parent recipe editor. Fix: ingredient onSubmit returns "norender", showModal checks for it and skips renderScreen. Modal still closes via closeModal/history.back, returning to the recipe editor with the new ingredient added.
This commit is contained in:
parent
cb5a916100
commit
d59013cc62
1 changed files with 2 additions and 1 deletions
|
|
@ -868,7 +868,7 @@ function showModal(html, onSubmit) {
|
|||
overlay.querySelector("#modal-cancel").onclick = () => closeModal();
|
||||
overlay.querySelector("#modal-ok").onclick = async () => {
|
||||
const ok = await onSubmit(overlay);
|
||||
if (ok !== false) { closeModal(); renderScreen(state.screen); }
|
||||
if (ok !== false) { closeModal(); if (ok !== "norender") renderScreen(state.screen); }
|
||||
};
|
||||
setTimeout(() => overlay.querySelector("input")?.focus(), 50);
|
||||
}
|
||||
|
|
@ -1689,6 +1689,7 @@ function showAddIngredientModal(cookingMethods, onAdd) {
|
|||
_product: null,
|
||||
});
|
||||
}
|
||||
return "norender"; // sub-modal: close without re-rendering parent screen
|
||||
});
|
||||
|
||||
const overlays = document.querySelectorAll(".modal-overlay");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue