mirror of
https://github.com/penpot/penpot.git
synced 2025-02-18 21:06:11 -05:00
🐛 Fix events inside webcomponent
This commit is contained in:
parent
3f473ca765
commit
5a34c25926
1 changed files with 9 additions and 1 deletions
|
@ -16,7 +16,7 @@ if (Mousetrap.addKeycodes) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = Mousetrap.prototype || Mousetrap;
|
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
|
// 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>
|
// to stop. It should be used like <div data-mousetrap-dont-stop>...</div>
|
||||||
// or :div {:data-mousetrap-dont-stop true}
|
// or :div {:data-mousetrap-dont-stop true}
|
||||||
|
@ -24,6 +24,14 @@ target.stopCallback = function(e, element, combo) {
|
||||||
return false
|
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
|
// stop for input, select, textarea and button
|
||||||
const shouldStop = element.tagName == "INPUT" ||
|
const shouldStop = element.tagName == "INPUT" ||
|
||||||
element.tagName == "SELECT" ||
|
element.tagName == "SELECT" ||
|
||||||
|
|
Loading…
Add table
Reference in a new issue