bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
38.67k stars 1.32k forks source link

[bug] load trigger stops hx-disabled-elt getting re-enabled #2925

Closed MichaelWest22 closed 2 months ago

MichaelWest22 commented 2 months ago

Description

When we init nodes and find a "load" trigger it does the request straight away and this request may disable some elements with hx-disabled-elt. However if these disabled elements have not yet had their nodeInit() run yet because they are placed lower in the page then when they later init they first de-init their internalData which removes the requestCount counter used to re-enable them again. So we need it to handle situations where requestCount is not set and currently it defaults this to -1 and no 0 because of the decrement. So to solve this I've just changed it to fall back to 1 which means that if either requestCount is undefined or if it is equal to 0 it will replace it with 1 and then after the decrement will be 0 and trigger the proper code to enable the element again.

Corresponding issue:

2767

Testing

Wrote a test to reproduce the issue with disabled-elt and load together and did a quick test in my test project to prove the disabled button re-enables as expected.

Checklist

1cg commented 2 months ago

Yep, just me being stupid