From c18b7527a761bd7da6c603444dd029cfcca55cdc Mon Sep 17 00:00:00 2001 From: Simon Huber Date: Sun, 6 Jun 2021 13:42:28 +0200 Subject: [PATCH] Fix #5760 - tm-focus-selector doesn't work in new windows (#5766) * Pass the original event to invokeActionString * Update rootwidget.js --- core/modules/keyboard.js | 2 +- core/modules/startup/rootwidget.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/modules/keyboard.js b/core/modules/keyboard.js index 1ae9ba482..1d818a25f 100644 --- a/core/modules/keyboard.js +++ b/core/modules/keyboard.js @@ -324,7 +324,7 @@ KeyboardManager.prototype.handleKeydownEvent = function(event) { if(key !== undefined) { event.preventDefault(); event.stopPropagation(); - $tw.rootWidget.invokeActionString(action,$tw.rootWidget); + $tw.rootWidget.invokeActionString(action,$tw.rootWidget,event); return true; } return false; diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index 6486cf6a2..8f119f02a 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -40,9 +40,10 @@ exports.startup = function() { // Install the tm-focus-selector message $tw.rootWidget.addEventListener("tm-focus-selector",function(event) { var selector = event.param || "", - element; + element, + doc = event.event ? event.event.target.ownerDocument : document; try { - element = document.querySelector(selector); + element = doc.querySelector(selector); } catch(e) { console.log("Error in selector: ",selector) }