f-update-url

This commit is contained in:
2026-11-11 17:16:21 -03:00
parent 3866b47741
commit 8c552d05d1
3 changed files with 100 additions and 3 deletions
@@ -26,6 +26,7 @@ import { INTERNAL_PREFIX, PARTIAL_SEARCH_PARAM } from "../../constants.ts";
export const PARTIAL_ATTR = "f-partial";
export const METHOD_ATTR = "f-method";
export const UPDATE_URL_ATTR = "f-update-url";
class NoPartialsError extends Error {}
@@ -341,9 +342,16 @@ document.addEventListener("submit", async (e) => {
};
}
// GET and POST update the URL by default, other methods don't
const updateUrl = e.submitter?.getAttribute(UPDATE_URL_ATTR) ??
el.getAttribute(UPDATE_URL_ATTR);
const shouldNavigate = updateUrl === null
? !isCustomMethod
: updateUrl !== "false";
try {
await withViewTransition(async () => {
await fetchPartials(actionUrl, partialUrl, true, init);
await fetchPartials(actionUrl, partialUrl, shouldNavigate, init);
});
} finally {
if (indicator !== undefined) {