-
Notifications
You must be signed in to change notification settings - Fork 252
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
Allow to pass an element to paste, copy, cut methods #1025
Comments
Thanks for opening this issue. We should aim to support Shadow DOM throughout all APIs. There are actually some lines in the internal utils to explicitly handle shadow hosts, but I think the considerations weren't properly documented (neither in the code nor in an issue or PR), so it's unclear which parts of the library already interact correctly with Shadow DOM and what would be necessary to add full support. (That is within the constraint to only handle The problem with any Would you rewrite this or file a new issue that targets (open) Shadow DOM support in the existing APIs? |
Thanks for getting back to me. I opened a new issue: #1026
I understand your concern. However, I do not understand why this is okay for |
I'm not sure we'd introduce
It gives flexibility and control. But that's exactly the opposite of our goal: We try to provide APIs that let the author describe an interaction and lift the burden to make correct assumptions about what exactly happens on the perceived interaction. |
Closing in favor of #1026 |
Problem description
Hello,
We want to use this library to write component tests for our web components. Since web components use builtin components within them (an
input
for example), the element that is currently focused might be different from the element we want to simulate user input on.A simple example of this is a text field. A text field is web component with an
input
inside of it. If you will it just wraps theinput
element. So while the text field is focused, the user input is actually supposed to happen on theinput
. Sadly currently with Shadow DOM enabled there is no way to usepaste
, because it just usesdocument.activeElement
:user-event/src/clipboard/paste.ts
Line 13 in ab1a6c4
Suggested solution
It would be great to have a utility API similar to
type()
to which you can just pass the element directly: https://testing-library.com/docs/user-event/utility/#typeThis would give people using Shadow DOM a way to use this library.
Additional context
It looks like Shadow DOM support is still further away: testing-library/dom-testing-library#413
The text was updated successfully, but these errors were encountered: