-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
buttons outside of forms with form=attribute get their values stuck #1749
Comments
Hey, I tried to reproduce the issue in this JSFiddle, though I don't get the same payload The button's value is correctly not included there, am I missing something? Also, please note I had to add the |
that explains the issue i was having with a test reproduction, thanks I'll test further. |
Thanks heaps for your call on N.B. your jsfiddle reproduces the issue for me, note you have to click the submit button and THEN change the input field? |
Oh right, I'm testing on Chrome From the top of my head I can't think what's causing that thing for you 😅 Let me know after that sleep session if it still happens 😆 |
got it! reproducing is more specific than I thought. codesandbox: https://codesandbox.io/p/sandbox/htmx-express-demo-forked-xn6zhp?welcome=true <!-- initial page -->
<form
hx-get="/xhr"
hx-trigger="input from:#t1, submit"
hx-target="#target"
hx-swap="outerHTML"
style="display: flex; flex-direction: column;"
>
<input id="t1" name="t1" value="textValue" autocomplete="off" />
<button name="b1" value="buttonValue1">Button 1</button>
<div id="target">
<button name="b2" value="buttonValue2">Button 2</button>
</div>
</form> <!-- response from /xhr -->
<div id="target">
<pre>${JSON.stringify(req.query)}</pre>
<button id="b2" name="b2" value="buttonValue2">Button 2</button>
</div> To reproduce:
Requirements to reproduce:
Given the above I'm not surprised i thought i was going nuts! |
Lmao that's so specific 😭 |
Using the link provided to codesandbox and using Firefox on my side all is working fine. Using Firefox 117.0 (64-bit). Open "https://xn6zhp-3000.csb.app/" into local Firefox instance. clicked Button 2. In don't see an issue with your demo code and HTMX also. |
You have reproduced the bug. The expected value on entering text is just {t1:...}. b2 should not be there, because the button was not pressed. |
Following up late on this @jwhitaker-swiftnav
|
Reproduction:
Click #submit :
{"b1":"buttonValue","t1":"textValue"}
(correct)Now change #idText (note we have swapped anything, form is the same element):
{"b1":"buttonValue", "t1":"changed"}
(incorrect, "b1" should not be there)I've tried to set up a test case for this in #1748 but I'm possibly stupid and my test breaks for reasons I can't understand.
I've also tried a partial fix in the same issue, which works for my reproduction, but breaks for other tests.
Related to #1559 but maybe not introduced there.
EDIT: this seems to only happen on firefox :(
The text was updated successfully, but these errors were encountered: