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

Support firing events inside of custom element shadow DOM #319

Closed
hontas opened this issue Jun 8, 2020 · 1 comment · Fixed by #320
Closed

Support firing events inside of custom element shadow DOM #319

hontas opened this issue Jun 8, 2020 · 1 comment · Fixed by #320
Labels

Comments

@hontas
Copy link
Contributor

hontas commented Jun 8, 2020

  • @testing-library/user-event version: 11.2.1
  • Testing Framework and version:
    • @open-wc/testing version 2.5.17
    • lit-html version 1.2.1
    • mocha version 6.2.3
  • DOM Environment: Chrome@83.0.4103.97

Relevant code or config

const el = render('custom-element');
const input = el.shadowRoot.querySelector('input');
userEvent.type(input, 'hello');

What you did:
I used userEvent.type with on an input-element inside a custom element's shadow DOM (in order to test its internal event listeners).

What happened:
Events did not fire on the input.

Reproduction repository:

Problem description:
The currentElement-helper returns element.ownerDocument.activeElement which return the custom element host instead of the focused element inside its shadow DOM. I'm guessing this is intended ;) but it is causing problems in this case, and it's not how the real DOM behaves when writing in an input-element inside a custom element.

Suggested solution:
Modify the currentElement-helper to return activeElement inside shadow DOM.

PR on its way :)

@hontas hontas mentioned this issue Jun 8, 2020
4 tasks
hontas pushed a commit to hontas/user-event that referenced this issue Jun 8, 2020
hontas pushed a commit to hontas/user-event that referenced this issue Jun 8, 2020
hontas pushed a commit to hontas/user-event that referenced this issue Jun 8, 2020
kentcdodds added a commit that referenced this issue Jun 8, 2020
* feat: add support for custom elements

Closes #319

* Update src/type.js

Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

* uncomplicate setup fn

* make it untouched

Co-authored-by: Pontus Lundin <pontus.lundin@ica.se>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds
Copy link
Member

🎉 This issue has been resolved in version 11.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

hontas pushed a commit to hontas/user-event that referenced this issue Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants