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
onChange events do not work on checkbox and radio button elements #880
Comments
It is interesting that if you use native events - it('event change', async () => {
const handle = vi.fn();
render(<App />);
const checkbox = screen.getByTestId('tea') as HTMLInputElement;
checkbox.addEventListener('change', handle); // ❗️
await userEvent.click(checkbox);
expect(handle).toHaveBeenCalled(); // ✅
}); But if the subscription to the it('event onChange', async () => {
const { container } = render(<App />);
const checkbox = screen.getByTestId('tea') as HTMLInputElement;
await userEvent.click(checkbox);
expect(container.innerHTML).toMatch('Selected Tea'); // ❌
}); It seems that the problem is in the interaction between React.js and |
…ggered when triggering a click().
…not-work-on-checkbox-and-radio-button-elements #880@patch: Fixes issue where react "onChange" listener never got tri…
Thank you for reporting @pkolt! 🙂 The issue has now been fixed. React is apparently overriding the getter and setter for the You can read more about the release here: |
Describe the bug
The
onChange
event is not generated when clicking on the checkbox and radio button elements. This breaks tests that used to work onjsdom
.This was already discussed in issue, but for some reason this ticket was closed. The problem is not solved and new
happy-dom
users face it again and again. I suggest fixing this problem or documenting this feature in thehappy-dom
.To Reproduce
https://github.com/pkolt/bug_checkbox_happy_dom
Expected behavior
When clicking on the
checkbox
andradio
button elements,onChange
events are triggered.The text was updated successfully, but these errors were encountered: