Skip to content

Commit 93667f2

Browse files
ianthomas23martinRenou
authored andcommitted
Fix context menu position on Voila, NbClassic and Notebook<7
Signed-off-by: Ian Thomas <[email protected]>
1 parent 8639639 commit 93667f2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

js/core/gridContextMenu.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DataModel } from '@lumino/datagrid';
44

55
import { CommandRegistry } from '@lumino/commands';
66

7-
import { Menu } from '@lumino/widgets';
7+
import { Menu, Widget } from '@lumino/widgets';
88

99
/**
1010
* An object which provides context menus for the data grid.
@@ -207,6 +207,15 @@ export class FeatherGridContextMenu extends GridContextMenu {
207207

208208
// Open context menu at location of the click event
209209
this._menu.open(hit.x, hit.y);
210+
211+
// Issue 422: menu should be first child of document.body not last child to work on all of
212+
// Jupyter Lab, Notebook < 7, NbClassic and Voila. Until this is available in lumino/widgets,
213+
// detach and reattach the menu here.
214+
const bodyFirstChild = document.body.firstElementChild;
215+
if (this._menu.node.parentElement == document.body && bodyFirstChild != this._menu.node) {
216+
Widget.detach(this._menu);
217+
Widget.attach(this._menu, document.body, bodyFirstChild as HTMLElement);
218+
}
210219
}
211220
}
212221

0 commit comments

Comments
 (0)