Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] partial on form submit #2409

Open
emilbillberg opened this issue Apr 19, 2024 · 0 comments
Open

[bug] partial on form submit #2409

emilbillberg opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working.

Comments

@emilbillberg
Copy link

When using partial with forms the url is updated in the browser to the url of the partial value (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>.

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants