testing-library / testing-library/user-event
Simulate MacOS X' Ctrl + Click as a contextmenu
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Problem description
On MacOS X, it's possible to trigger a contextmenu event with ctrl + click. This gives a contextmenu event with { button: 0, buttons: 1 } (as opposed to { button: 2, buttons: 2 } for a normal right click). It would be good to be able to trigger this somehow, and I haven't found that the user-event library can do it at the moment.
Suggested solution
This would be my prefered solution:
const user = userEvent.setup({ environment: 'macosx' });
await user.keyboard("{Shift>}");
await user.click(target);
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the library's existing click and contextmenu event handling, then inspect how keyboard modifiers and platform-specific behavior are represented. The change is complete when Ctrl+Click can produce a contextmenu event with button 0 and buttons 1, with tests covering the proposed macOS environment option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100