-
Notifications
You must be signed in to change notification settings - Fork 251
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
Checkbox should not be checked when clicking Label of disabled checkbox #1057
Comments
Also able to replicate using |
Hey there! I confirm the problem.
Test sample const user = userEvent.setup();
test("should be unchecked after the click on disabled label", async () => {
// Arrange
render(<Checkbox disabled label="My label" />);
const label = screen.getByText("My label");
const checkbox = screen.getByLabelText("My label");
// Act & Assert
expect(checkbox).not.toBeChecked();
await user.click(label);
expect(checkbox).not.toBeChecked(); // fails on this line...
}); |
Hi there. I got the same issue with radio. |
Similar example with plain jsdom: https://stackblitz.com/edit/vitest-dev-vitest-azkvzh?file=test/basic.test.ts From a very naive point of view, I would say that line 12 and 13 in click.ts should be swapped, so that the click is only dispatched if the "control" was successfully focused. |
When a label with a control is clicked, the click is forwarded even if the control is not focusable (i.e. disabled or hidden). This change addresses that issue. Resolves testing-library#1057 Also, updating the how to contribute tutorial link in CONTRIBUTING.md.
When a label with a control is clicked, the click is forwarded even if the control is not focusable (i.e. disabled or hidden). This change addresses that issue. Resolves testing-library#1057 Also, updating the how to contribute tutorial link in CONTRIBUTING.md.
When a label with a control is clicked, the click is forwarded even if the control is not focusable (i.e. disabled or hidden). This change addresses that issue. Resolves testing-library#1057 Also, updating the how to contribute tutorial link in CONTRIBUTING.md.
When a label with a control is clicked, the click is forwarded even if the control is not focusable (i.e. disabled or hidden). This change addresses that issue. Resolves testing-library#1057 Also, updating the how to contribute tutorial link in CONTRIBUTING.md.
I have the same problem after I upgraded to last version 14.4.3 from 13.5.0. In 13.5.0 it works as expected. Fix it, please. |
Had to downgrade to 13.5.0 to unblock my tests (instead of using |
Reproduction example
https://codesandbox.io/s/sparkling-sky-5g3t2j?file=/src/App.test.js
Prerequisites
<label><input type="checkbox" disabled /> Disabled Checkbox</label>
Expected behavior
checkbox should not be checked
Actual behavior
checkbox is checked
User-event version
14.4.3
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response
The text was updated successfully, but these errors were encountered: