Skip to content

Commit

Permalink
Fix context menu position on Voila, NbClassic and Notebook<7
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Thomas <[email protected]>
  • Loading branch information
ianthomas23 authored and martinRenou committed Apr 25, 2024
1 parent 8639639 commit 93667f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/core/gridContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DataModel } from '@lumino/datagrid';

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

import { Menu } from '@lumino/widgets';
import { Menu, Widget } from '@lumino/widgets';

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

// Open context menu at location of the click event
this._menu.open(hit.x, hit.y);

// Issue 422: menu should be first child of document.body not last child to work on all of
// Jupyter Lab, Notebook < 7, NbClassic and Voila. Until this is available in lumino/widgets,
// detach and reattach the menu here.
const bodyFirstChild = document.body.firstElementChild;
if (this._menu.node.parentElement == document.body && bodyFirstChild != this._menu.node) {
Widget.detach(this._menu);
Widget.attach(this._menu, document.body, bodyFirstChild as HTMLElement);
}
}
}

Expand Down

0 comments on commit 93667f2

Please sign in to comment.