Skip to content
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

userEvent.click doesn't ignore hidden elements as the documentation says #1145

Open
haocheng6 opened this issue Jul 12, 2023 · 0 comments
Open
Labels
bug Something isn't working

Comments

@haocheng6
Copy link

Reproduction example

https://codesandbox.io/s/user-event-invisible-button-xpw2kf

Prerequisites

  1. Render an invisble button:
<button onClick={() => setClicked(true)} style={{visibility: 'hidden'}}>
  Click me!
</button>
  1. Select the button.
  2. Click the button using the click function of userEvent.

Expected behavior

The click function shouldn't work on invisible HTML elements. Maybe an error should be thrown in that case.

Actual behavior

Even though the documentation says

It adds visibility and interactability checks along the way and manipulates the DOM just like a user interaction in the browser would. It factors in that the browser e.g. wouldn't let a user click a hidden element or type in a disabled text box.

the click function still works on the invisible button.

User-event version

14.4.3

Environment

No response

Additional context

No response

@haocheng6 haocheng6 added bug Something isn't working needs assessment This needs to be looked at by a team member labels Jul 12, 2023
@ph-fritsche ph-fritsche removed the needs assessment This needs to be looked at by a team member label Jul 24, 2023
sethwbarton pushed a commit to sethwbarton/user-event that referenced this issue Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants