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

Better graceful degradation of boosted form element #2802

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

NDoolan360
Copy link
Contributor

Description

The expected behaviour of a form is not currently adhered to in htmx, making hx-boost degrade in an unexpected way for forms. (I have only tested this on chrome, safari and firefox)

When the action attribute is not set on a form with hx-boost and there are query params in the url, these values are included in the request as well as any values from the form. This does not match how forms normally handle an empty action attribute without hx-boost.

Another attempt at #1811

Corresponding issue: #1788

Testing

I have tested this manually in one of my own projects.
I'm happy to implement anything in the htmx test suite but unsure how to mock query params in url in the tests I looked into.

Checklist

  • I have read the contribution guidelines
  • I have targeted this PR against the correct branch (master for website changes, dev for
    source changes)
  • This is either a bugfix, a documentation update, or a new feature that has been explicitly
    approved via an issue
  • I ran the test suite locally (npm run test) and verified that it succeeded - 652 passing (5s), 3 pending

@NDoolan360
Copy link
Contributor Author

NDoolan360 commented Aug 7, 2024

Hmmm, thinking there may need to be another check that the method is "GET" for this instance, to not break behaviour for post requests.
The form submission algorithm (step 26 table) outlines the different schemes for how to handle the url.
For http/https GET requests, this is "Mutate action URL", where notably:

Let query be the result of running the application/x-www-form-urlencoded serializer with pairs and encoding.

Set parsed action's query component to query.

This seems to imply the existing query component is overriden.

@Telroshan Telroshan added bug Something isn't working needs test PR needs a test labels Aug 8, 2024
@Telroshan
Copy link
Collaborator

Hey, could you add a test case to the test suite, to first confirm the issue with the lib's current state, then confirm that your PR fixes it? (You might also want to add a test case for POST)
Thanks!

@NDoolan360
Copy link
Contributor Author

NDoolan360 commented Aug 12, 2024

Hey @Telroshan, I've added some tests.
Please let me know if there's more you need. 😄


@alexpetros
Copy link
Collaborator

Yup, this looks good

@alexpetros alexpetros added ready for review Issues that are ready to be considered for merging and removed needs test PR needs a test labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for review Issues that are ready to be considered for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants