question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disabled checkbox click still fires `onChange`

See original GitHub issue

this 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:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Dhaltoncommented, Apr 18, 2019

@Gpx I’ll take a crack at it, sure. 😄

0reactions
Dhaltoncommented, Apr 25, 2019

@Gpx Got a PR to handle this for radio buttons as well. Sorry for the wait, I’ve been busy! 😃 #107

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found