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
|
// create and attach event listeners
|
||||||
var me = this;
|
var me = this;
|
||||||
var list = this.dom.list;
|
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
|
// hide menu on click outside of the menu
|
||||||
var target = event.target;
|
var target = event.target;
|
||||||
if ((target != list) && !me._isChildOf(target, list)) {
|
if ((target != list) && !me._isChildOf(target, list)) {
|
||||||
|
@ -249,7 +250,7 @@ ContextMenu.prototype.show = function (anchor, contentWindow) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.eventListeners.keydown = util.addEventListener(window, 'keydown', function (event) {
|
this.eventListeners.keydown = util.addEventListener(rootNode, 'keydown', function (event) {
|
||||||
me._onKeyDown(event);
|
me._onKeyDown(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue