bigskysoftware/htmx

Preload doesn't include submit button values

Opened this issue · 0 comments

(My apologies if this has been raised and I've missed the previous issue)

It seems, as far as I am able to reproduce, that the name and value provided on a form's submit button are not used in the URI of the preload's request, thus meaning it effectively does not fetch the correct resource, and by extension preloading does not work.

If the button lacks values, then it will preload and use the cached version, in a manner similar to what would be expected if the button had a name and value.

Another thing I noticed when trying to find a work around:

  • Using hx-get and hx-include submits the preload for the nearest form (in the same manner as I am flagging), but doesn't reflect the final request.

Tested with the following HTML:

<html>
    <head>
        <script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js"></script>
        <script src="https://cdn.jsdelivr.net/npm/htmx-ext-preload@2.1.0"></script>
    </head>
    <body hx-ext="preload" hx-boost="true">
        <form
            action="/scratch.html"
            method="get"
            preload
        >
            <button
                name="foo"
                value="bar"
                type="submit"
            >Submit</button>
        </form>
    </body>
</html>

Effective URIs:

  • Preload: /scratch.html
  • Actual: /scratch.html?foo=bar

(Reproduced with Firefox 141.0)

Edit: simplified example