[htmx 4] Incorrect innerHTML swap on radio input
While migrating from htmx 2 to 4, one of my page broke in a very interesting way. I have a little search form that looks like this (I simplified it by removing labels and unnecessary divs, it's generated from django so it's a bit verbose)
<form hx-get="/clubs" hx-target="#content" hx-swap="innerHTML" hx-push-url="true" hx-disable="find input, find button">
<fieldset>
<legend>État du club :</legend>
<div id="id_club_status">
<label for="id_club_status_0">
<input type="radio" name="club_status" value="True" required id="id_club_status_0" checked />Actif
</label>
</div>
<div>
<label for="id_club_status_1">
<input type="radio" name="club_status" value="False" required id="id_club_status_1" />Inactif
</label>
</div>
<div>
<label for="id_club_status_2">
<input type="radio" name="club_status" value="" required id="id_club_status_2" />Tous les clubs
</label>
</div>
</fieldset>
<button class="btn btn-blue margin-bottom"><i class="fa fa-magnifying-glass"></i>Search</button>
</form>
When using the form, the request is sent once and I receive the expected html fragment with the correct value. However, when I change the radio input value, it starts glitching.
- On firefox, I see the radio value reset and then get to the correct value
- On chrome based browser, it resets and then the checked value disappear
I've noticed that when I enable transitions, this bad behaviour stops, it's also "fixed" when using morphing which suggests that something is wrong with transitions. This worked properly with htmx 2 and I don't see anything that should have changed behaviour with the new version.
Here what it looks like on chrome https://github.com/user-attachments/assets/3018f0ab-1733-4488-9996-7df69c39af5c
Original discussion https://discord.com/channels/725789699527933952/1546997168898965615
Source: bigskysoftware/htmx