Skip to content

Commit 5aa41f5

Browse files
Mariusz Jurowiczscottdraves
authored andcommitted
#6127 fix opening the table colum menu outside jupyter's cell (#6128)
* #6127 fix opening the table colum menu outside jupyter's cell * #6127 move menu otside the cell
1 parent e55b416 commit 5aa41f5

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

beakerx/js/src/tableDisplay/css/datatables.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ $highlight-blue: #39a9ed;
2828
}
2929

3030
.dtcontainer {
31+
display: inline-block;
3132
position: relative;
32-
width: 100%;
33+
width: auto;
34+
max-width: 100%;
3335
border: 1px solid transparent;
3436
padding: 10px 20px;
3537

beakerx/js/src/tableDisplay/tableHeaderMenu/HeaderMenu.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@ export default abstract class HeaderMenu {
5252
$(this.menu.node).off('keydown.HeaderMenu', '.dropdown-menu-search input', this.handleKeydownEvent)
5353
}
5454

55-
protected getMenuPosition($notebookCell, $trigger) {
56-
const $cell = $trigger.parent();
55+
protected getMenuPosition($container: any, $trigger: any) {
5756
const rectObject = $trigger[0].getBoundingClientRect();
57+
const containerRectObj = $container[0].getBoundingClientRect();
5858
const pageHeight = window.innerHeight || document.documentElement.clientHeight;
5959
const pixelsBelowViewport = Math.ceil($(this.menu.contentNode).height() + rectObject.bottom - pageHeight);
60-
const triggerHeight = $trigger.height() || 20;
60+
const triggerHeight = rectObject.height || 20;
6161

6262
return {
63-
top: ($cell.offset().top - $notebookCell.offset().top + triggerHeight - (pixelsBelowViewport > 0 ? pixelsBelowViewport : 0)),
64-
left: $cell.offset().left - $notebookCell.offset().left + (pixelsBelowViewport > 0 ? triggerHeight : 0)
63+
top: rectObject.bottom - containerRectObj.top + triggerHeight - (pixelsBelowViewport > 0 ? pixelsBelowViewport : 0),
64+
left: rectObject.left + (pixelsBelowViewport > 0 ? triggerHeight : 0)
6565
};
6666
}
6767

68-
open($notebookCell: any, $trigger: any, submenuIndex?: number): void {
69-
Widget.attach(this.menu, $notebookCell[0]);
68+
open($container: any, $trigger: any, submenuIndex?: number): void {
69+
Widget.attach(this.menu, $container[0]);
7070
this.menu.node.style.top = null;
7171
this.menu.node.style.bottom = '0px';
7272
this.menu.addClass('open');
7373
this.menu.show();
7474

75-
const menuPosition = this.getMenuPosition($notebookCell, $trigger);
75+
const menuPosition = this.getMenuPosition($container, $trigger);
7676
this.menu.node.style.top = menuPosition.top + 'px';
7777
this.menu.node.style.left = menuPosition.left + 'px';
7878
this.menu.node.style.bottom = null;
@@ -132,7 +132,7 @@ export default abstract class HeaderMenu {
132132
if (menuItem.shortcut) {
133133
this.commands.addKeyBinding({
134134
keys: [menuItem.shortcut],
135-
selector: '.cell',
135+
selector: 'body',
136136
command: menuItem.title
137137
});
138138
}

beakerx/js/src/tableDisplay/tableHeaderMenu/IndexMenu.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export default class IndexMenu extends HeaderMenu {
4141
event.preventDefault();
4242
event.stopPropagation();
4343

44-
self.open($trigger.closest('.cell'), $trigger);
44+
const $container = self.scopeElement.closest('.container');
45+
self.open($container.length ? $container : $(document.body), $trigger);
4546
});
4647

4748
this.createItems(this.menuItems, this.menu);

beakerx/js/src/tableDisplay/tableHeaderMenu/createColumnMenus.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export default function createColumnMenus(scope) {
4747

4848
for(let i = 0; i < menus.length; i++) {
4949
if (menus[i].columnIndex === colIdx) {
50-
menus[i].open($(scope.element).closest('.cell'), $(this));
50+
const $container = scope.element.closest('.container');
51+
menus[i].open($container.length ? $container : $(document.body), $(this));
5152
break;
5253
}
5354
}

0 commit comments

Comments
 (0)