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

Simulate MacOS X' Ctrl + Click as a contextmenu #924

Open
julienw opened this issue Apr 12, 2022 · 1 comment
Open

Simulate MacOS X' Ctrl + Click as a contextmenu #924

julienw opened this issue Apr 12, 2022 · 1 comment
Labels
enhancement New feature or request needs specification The desired behavior is not defined yet

Comments

@julienw
Copy link

julienw commented Apr 12, 2022

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

@julienw julienw added enhancement New feature or request needs assessment This needs to be looked at by a team member labels Apr 12, 2022
@ph-fritsche
Copy link
Member

We currently implement a combinationBehavior on keydown that only implements "select all" for Ctrl+A. This also behaves differently on Mac. See #778 (comment)

I think we should not hard-code but implement those combinations as plugins to the event/behavior and then let the user supply the plugin per setup().

import userEvent, { InputScheme } from `@testing-library/user-event`

// Could also extend it and supply your own
const user = userEvent.setup({inputScheme: InputScheme.MacOSX})

@ph-fritsche ph-fritsche added needs specification The desired behavior is not defined yet and removed needs assessment This needs to be looked at by a team member labels Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs specification The desired behavior is not defined yet
Projects
None yet
Development

No branches or pull requests

2 participants