0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

🐛 Fix events inside webcomponent

This commit is contained in:
Juanfran 2024-03-22 11:31:53 +01:00 committed by Andrey Antukh
parent 3f473ca765
commit 5a34c25926

View file

@ -16,7 +16,7 @@ if (Mousetrap.addKeycodes) {
}
const target = Mousetrap.prototype || Mousetrap;
target.stopCallback = function(e, element, combo) {
target.stopCallback = function (e, element, combo) {
// if the element has the data attribute "mousetrap-dont-stop" then no need
// to stop. It should be used like <div data-mousetrap-dont-stop>...</div>
// or :div {:data-mousetrap-dont-stop true}
@ -24,6 +24,14 @@ target.stopCallback = function(e, element, combo) {
return false
}
if ('composedPath' in e && typeof e.composedPath === 'function') {
// For open shadow trees, update `element` so that the following check works.
const initialEventTarget = e.composedPath()[0];
if (initialEventTarget !== e.target) {
element = initialEventTarget;
}
}
// stop for input, select, textarea and button
const shouldStop = element.tagName == "INPUT" ||
element.tagName == "SELECT" ||