vue3-context-menu icon indicating copy to clipboard operation
vue3-context-menu copied to clipboard

How to append the menu's div inside the App's div?

Open alexgheorghiu opened this issue 10 months ago • 2 comments

How can I generate the menu's div inside the App's div?

Details

image

Right now the menu's div is created outside the App's div and I can not reach to it (for some test units).

Trying to get around this issue elegantly so I also asked for ideas here: https://stackoverflow.com/questions/78296814/how-to-reference-html-elements-from-ouside-the-app-in-vue

alexgheorghiu avatar Apr 09 '24 09:04 alexgheorghiu

Menu is mount to body by default, you can change it use getContainer property in MenuOptions, Change container.

ContextMenu.showContextMenu({
  getContainer: () => document.querySelector('#app'),
  //...
})

imengyu avatar Apr 10 '24 03:04 imengyu

Thanks. That helped. I need that to simulate a right click using vue test utils. I sense I'm a little bit closer but still need a way to figure why the wrapper.click('click.right') does not trigger the menu to appear to be added to the DOM (while it works in a real browser)

alexgheorghiu avatar Apr 10 '24 08:04 alexgheorghiu