fix: don't intercept forms without explicit f-partial inside f-client-nav (#3722)

Fixes #3473

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bartek Iwańczuk
2026-03-29 19:07:54 +00:00
committed by GitHub
co-authored by Claude Opus 4.6
parent caeebd88a5
commit dd1ecf3b16
2 changed files with 53 additions and 1 deletions
+10 -1
View File
@@ -231,12 +231,21 @@ document.addEventListener("submit", async (e) => {
return;
}
const hasExplicitPartial = e.submitter?.hasAttribute(PARTIAL_ATTR) ||
e.submitter?.hasAttribute("formaction") ||
el.hasAttribute(PARTIAL_ATTR) ||
el.hasAttribute("action");
const rawPartialUrl = e.submitter?.getAttribute(PARTIAL_ATTR) ??
e.submitter?.getAttribute("formaction") ??
el.getAttribute(PARTIAL_ATTR) ?? el.action;
const rawActionUrl = e.submitter?.getAttribute("formaction") ?? el.action;
if (rawPartialUrl !== "") {
// Only intercept forms that explicitly opt in to partial navigation
// via f-partial, formaction, or an explicit action attribute. Without
// this check, every form inside f-client-nav would be intercepted
// because el.action is always non-empty (defaults to the current URL).
if (hasExplicitPartial && rawPartialUrl !== "") {
e.preventDefault();
const partialUrl = new URL(rawPartialUrl, location.href);