Disabled checkbox click still fires `onChange`
See original GitHub issuethis PR on react-testing-library
was an attempt to address this problem:
https://github.com/kentcdodds/dom-testing-library/pull/217
but it was closed in favor of addressing in this library. From what I can tell, it has not been addressed in this library. In my test, I’m still seeing the onChange
handler being called for an <input type="checkbox" disabled />
when I call userEvent.click(checkbox)
.
This is not how browsers behave, fwiw
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Can I disable a checkbox but still have its events triggered?
It's not clear whether you want to check the disabled checkbox using an <a> link or trigger a click event attached to the...
Read more >user-event v13 - Testing Library
If they are not closed explicitly, then events will be fired to close them automatically (to disable this, set the skipAutoClose option to...
Read more >HTML DOM Input Checkbox disabled Property - W3Schools
The disabled property sets or returns whether a checkbox should be disabled, or not. A disabled element is unusable and un-clickable. Disabled elements...
Read more >lightning-input - documentation - Salesforce Developers
A lightning-input component creates an HTML <input> element. This component supports the following input types: checkbox; checkbox-button; date; datetime ...
Read more >Checkbox - Reach UI
onChange ?: (event: React.ChangeEvent<HTMLInputElement>) => void;. The callback that is fired when the checkbox value is changed. CustomCheckbox value. value ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Gpx I’ll take a crack at it, sure. 😄
@Gpx Got a PR to handle this for radio buttons as well. Sorry for the wait, I’ve been busy! 😃 #107