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

feat: honor keyboardState in pointer events #713

Closed
malipramod opened this issue Aug 9, 2021 · 2 comments · Fixed by #751
Closed

feat: honor keyboardState in pointer events #713

malipramod opened this issue Aug 9, 2021 · 2 comments · Fixed by #751
Labels
enhancement New feature or request
Milestone

Comments

@malipramod
Copy link

malipramod commented Aug 9, 2021

  • @testing-library/user-event version:

"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.8.3",

  • Testing Framework and version:
  • DOM Environment:

Relevant code or config

What you did:

fireEvent.keyDown(element, { key: "Control", code: 17, charCode: 17 })
fireEvent.click(element);
fireEvent.keyUp(element, { key: "Control", code: 17, charCode: 17 })

What happened:
Doesn't recognize the keyboard event

Reproduction repository:

Problem description:
How to perform a ctrl+click or cmd+click with fireEvent or userEvent?

Suggested solution:

@ph-fritsche
Copy link
Member

fireEvent.click(element, {ctrlKey: true}) // for just the click event
// or
userEvent.click(element, {ctrlKey: true}) // for hover, mousedown, mouseup...

Currently we don't support passing a keyboardstate to the mouse event simulations.
We might add a shared state in the future as discussed in #703

@ph-fritsche ph-fritsche added the enhancement New feature or request label Aug 9, 2021
@malipramod
Copy link
Author

@ph-fritsche Thank you! This worked! Feel free to close this.

@ph-fritsche ph-fritsche changed the title Control click with fireEvent, userEvent feat: honor keyboardState in pointer events Oct 16, 2021
@ph-fritsche ph-fritsche added this to the userEvent v14 milestone Oct 16, 2021
@ph-fritsche ph-fritsche linked a pull request Oct 20, 2021 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants