Support HTTP methods beyond GET/POST in partial form submissions
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- deno, typescript
- Domain
- frontend
Research direction
Start at the guard in packages/fresh/src/runtime/client/partials.ts around line 268, then check the fetch() call around line 309 and any nearby partial form tests. Confirm which methods should pass through and how the submission behavior is covered. Done means partial form submissions support the intended HTTP methods while GET and POST continue to work.
Written by the indexing model from the issue text.
Description
Summary
Fresh's partial form handling currently only supports GET and POST methods. The guard at partials.ts:268 bails out for any other method:
if (lowerMethod !== "get" && lowerMethod !== "post") {
return;
}
However, the code below (line 309) already passes method: lowerMethod to fetch(), so DELETE/PATCH/PUT would work if the guard were removed or expanded.
Motivation
Users want to use REST-style handlers with partials:
export const handler = define.handlers({
POST(ctx) {
return ctx.render(<Partial name="body">post!</Partial>);
},
DELETE(ctx) {
return ctx.render(<Partial name="body">delete!</Partial>);
},
PATCH(ctx) {
return ctx.render(<Partial name="body">patch!</Partial>);
},
});
export default define.page(function Home() {
return (
<div f-client-nav>
<Partial name="body">
<form>
<button type="submit" formmethod="POST">post</button>
<button type="submit" formmethod="DELETE">delete</button>
<button type="submit" formmethod="PATCH">patch</button>
</form>
</Partial>
</div>
);
});
Currently the workaround is creating a Form island that uses fetch() internally, which is janky.
Considerations
formmethod="DELETE"is not valid per the HTML spec — browsers without JS (or before the partial script loads) would treat unknown methods as GET. This is a progressive enhancement tradeoff.- One option is a Fresh-specific attribute (e.g.
f-method="DELETE") to make it explicit that this only works with client nav enabled. - The minimal change is just removing/expanding the guard at line 268, since the fetch plumbing already handles arbitrary methods.
References
- Discord discussion
- Similar pattern popularized by htmx (
hx-delete,hx-patch, etc.)
- Dominant language
- TypeScript
- Stars
- 13.8k
- Forks
- 757
- Avg merge
- 3m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from freshframework/fresh
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
freshframework/fresh#3920 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
freshframework/fresh#3833 ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
freshframework/fresh#3918 · 1 comment · 4 reactions ·
-
Tab title doesn't update to <Head> <title> when navigating to a page with another <title>Possibly taken @1AbdullahButt claimed this 7 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 57/100
freshframework/fresh#3916 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
freshframework/fresh#3911 ·
All issues in freshframework/fresh
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tintinweb/pi-subagents#459 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
danielmiessler/LifeOS#2830 ·
Maintainers usually reply within 6 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: client enhancement priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
opensro-dev/opensro#3681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day