-
-
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
hx-disabled-elt causes unhandled exception when targets not found #2913
Comments
yeah interesting bug. I've tracked it down to the querySelectorAllExt() function which for the also note that You can work around this issue in your case by not using find and instead finding the components in another way. for example you could add a custom class to all elements you want to disable like "hx-disable" and then use ".hx-disable" as the selector which allows it to find multiple avoiding the , issue and the exception issue. |
Makes sense, after a lot of debugging I gathered it was something along those lines returning null but I wasn't sure where.
Interestingly, this works just fine now. The order seems to be important (button first failed, but inputs then button is fine).
This would be the solution but there are a number of forms on the same page and so it gets to be a lot to sort. What would be much easier is some type of find or all children for inputs. The find or closest is great but when multiple items requiring css selectors is more of a pain than the keywords. |
Added a couple of PR's to address your issue and also fix the problem I found in the multi find selector that came from the documentation. |
Awesome, I took a look, seems like a straightforward fix! Oddly enough to note though, the example from the docs, that shouldn't work based on your PR works fine. My inputs and buttons are disabled when here's an inflight request. |
Hi there,
Following along with the example of settings for
hx-disabled-elt
, and taking advantage of the inheritance, when the elements specified in thehx-disabled-elt
are not found htmx fails withUncaught TypeError: Cannot read properties of null (reading 'htmx-internal-data')
.After a fair bit of debugging, the issue comes from a setup like this:
In the above example, the elements in the form are disabled and work great, when when the second link it pressed, because there are no child elements of
input
orbutton
for find to work on, the uncaught exception is generated.When the elements specified in a
hx-disabled-elt
are not found (or not children exist) the failure should be more graceful, especially since as an inheritable property it may be used in a number of different circumstances.This is occurring with htmx 2.0.2.
The text was updated successfully, but these errors were encountered: