# Mousetrap.js doesn’t properly stop callbacks for events originating from a shadow DOM

**URL:** <https://meta.discourse.org/t/mousetrap-js-doesn-t-properly-stop-callbacks-for-events-originating-from-a-shadow-dom/102757>\
**Category:** Development\
**Created:** [26.Ноябрь.2018 10:10:05 UTC](https://meta.discourse.org/t/mousetrap-js-doesn-t-properly-stop-callbacks-for-events-originating-from-a-shadow-dom/102757 "2018-11-26T10:10:05Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![kleinfreund](https://avatars.discourse-cdn.com/v4/letter/k/a6a055/32.png) [@kleinfreund](https://meta.discourse.org/u/kleinfreund)\
**Post date:** [26.Ноябрь.2018 10:10:05 UTC](https://meta.discourse.org/t/mousetrap-js-doesn-t-properly-stop-callbacks-for-events-originating-from-a-shadow-dom/102757/1 "2018-11-26T10:10:05Z")

</div>

I’m experimenting with shadow DOM in a Discourse plugin I’m writing and noticed that mousetrap.js is not stopping callbacks for events that originate in the shadow DOM. For example, pressing u in an input element triggers the Discourse shortcut for history back navigation; thus, stopping me from filling out any forms.

I’m mainly adding this as a reference for people running into this in the future because it’s unlikely this can be fixed in Discourse without replacing mousetrap.js (except for monkey-patching the file).

- Upstream issue: [Stop events occuring in input fields when using a shadow DOM · Issue #245 · ccampbell/mousetrap · GitHub](https://github.com/ccampbell/mousetrap/issues/245)

- Open pull request (stale, unfortunately): [Don't fire events if you're inside a textfield/input in a shadow DOM by robinsk · Pull Request #254 · ccampbell/mousetrap · GitHub](https://github.com/ccampbell/mousetrap/pull/254)

- Possible fix:

---

_[View the full topic](https://meta.discourse.org/t/mousetrap-js-doesn-t-properly-stop-callbacks-for-events-originating-from-a-shadow-dom/102757)._
