From 5a34c25926cf184693c742479e3a52e36e553548 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Fri, 22 Mar 2024 11:31:53 +0100 Subject: [PATCH] :bug: Fix events inside webcomponent --- frontend/src/app/main/data/shortcuts_impl.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/shortcuts_impl.js b/frontend/src/app/main/data/shortcuts_impl.js index 9be5beb059..e381cc150b 100644 --- a/frontend/src/app/main/data/shortcuts_impl.js +++ b/frontend/src/app/main/data/shortcuts_impl.js @@ -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
...
// 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" ||