0

I'm using react-contextmenu and I was able to trigger contextmenu in v13 by following

userEvent.click(node, { button: 2 });

but after upgrading v14 I'm not able to trigger contextmenu or right-click event of an element

Tried fireEvent.contextMenu(node) and various ways but didn't work.

Metehan Senol
  • 651
  • 4
  • 10
  • Probably to do with this https://github.com/testing-library/user-event/pull/784/. The second parameter got removed, so you now need to be clicking a button which genuinely does trigger the event you need, without that modifier. It's to force you to write better tests. What purpose did `button: 2` serve initially? – adsy May 05 '23 at 19:23

1 Answers1

0

Bit of a longshot but try changing to the newer API:

  userEventuser.pointer({ keys: '[MouseRight>]', target: node })
adsy
  • 8,531
  • 2
  • 20
  • 31