Add listeners to list (shadow) root instead of window,
make context menus work in Shadow DOM. Fixes https://github.com/josdejong/jsoneditor/issues/447
This commit is contained in:
parent
c51db94f88
commit
b1a939d680
|
@ -240,7 +240,8 @@ ContextMenu.prototype.show = function (anchor, contentWindow) {
|
|||
// create and attach event listeners
|
||||
var me = this;
|
||||
var list = this.dom.list;
|
||||
this.eventListeners.mousedown = util.addEventListener(window, 'mousedown', function (event) {
|
||||
var rootNode = list.getRootNode && list.getRootNode() || window;
|
||||
this.eventListeners.mousedown = util.addEventListener(rootNode, 'mousedown', function (event) {
|
||||
// hide menu on click outside of the menu
|
||||
var target = event.target;
|
||||
if ((target != list) && !me._isChildOf(target, list)) {
|
||||
|
@ -249,7 +250,7 @@ ContextMenu.prototype.show = function (anchor, contentWindow) {
|
|||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
this.eventListeners.keydown = util.addEventListener(window, 'keydown', function (event) {
|
||||
this.eventListeners.keydown = util.addEventListener(rootNode, 'keydown', function (event) {
|
||||
me._onKeyDown(event);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue