Closed emilbillberg closed 2 months ago
When using partial with forms the url is updated in the browser to the url of the partial value (f-partial).
f-partial
Example:
<div f-client-nav> <form method="get" action="/search" f-partial="/partials/test"> <input type="text" name="q" /> <button type="submit">Search</button> </form> </div>
On submit event the url in the browser is updated to /partials/test?q=<query>. I would expect the url in the browser to be updated to /search?q=<query>.
submit
/partials/test?q=<query>
/search?q=<query>
When digging through the code I can see the function maybeUpdateHistory with the url of the partial location is called. https://github.com/denoland/fresh/blob/main/src/runtime/entrypoints/main.ts#L1096
maybeUpdateHistory
A solution would be to create two different url variables, one from f-partial and one from action. Both of them need to contain the new search params from the form. That approach seems to be done for the click event https://github.com/denoland/fresh/blob/main/src/runtime/entrypoints/main.ts#L958-L960
action
click
This has been affecting my app too. Thanks @emilbillberg!
When using partial with forms the url is updated in the browser to the url of the partial value (
f-partial
).Example:
On
submit
event the url in the browser is updated to/partials/test?q=<query>
. I would expect the url in the browser to be updated to/search?q=<query>
.When digging through the code I can see the function
maybeUpdateHistory
with the url of the partial location is called. https://github.com/denoland/fresh/blob/main/src/runtime/entrypoints/main.ts#L1096A solution would be to create two different url variables, one from
f-partial
and one fromaction
. Both of them need to contain the new search params from the form. That approach seems to be done for theclick
event https://github.com/denoland/fresh/blob/main/src/runtime/entrypoints/main.ts#L958-L960