-
Notifications
You must be signed in to change notification settings - Fork 497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ipydatagrid
context menu opens in wrong position when rendered in voila
#930
Comments
Thanks @ibdafna for reporting this. This is reproducible on Binder with this gist: https://gist.github.com/jtpio/73fdfaa8881f3f68b46173eb8300952f |
Looks like this part of the code might be triggered? |
@jtpio that's the code which triggers opening the lumino context menu, but the weird positioning only happens in Voila |
@jtpio let me know if there's anything else you need from me or if I've missed something! Thank you 😄 |
We could check whether the issue also happens with this PR, which switches to a lab-based application for the frontend: #846. We might have to make Another guess could be the DOM structure being different between lab and voila. |
@jtpio anything I can do on my end to help expedite? |
@ibdafna I looked into it a bit and here are some findings. This seems to be because the context menu is positioned as an According to https://developer.mozilla.org/en-US/docs/Web/CSS/position#absolute_positioning and https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block:
Which probably explains why it always tries to "scroll back up" when the context menu is opened since the viewport coordinates would be used to position the element, but relative to the top of the html document. Testing locally with a diff like the following seems to be doing the trick: diff --git a/js/feathergrid.ts b/js/feathergrid.ts
index 082d776..8cd7d68 100644
--- a/js/feathergrid.ts
+++ b/js/feathergrid.ts
@@ -163,8 +163,8 @@ class FeatherGridMouseHandler extends BasicMouseHandler {
if (isMenuClick) {
this._grid.contextMenu.open(grid, {
...hit,
- x: event.clientX,
- y: event.clientY,
+ x: event.clientX + window.scrollX,
+ y: event.clientY + window.scrollY,
});
return;
} context-menu-ipydatagrid.mp4 |
@jtpio this looks good, thank you. I'll need to check whether this logic change could break existing apps, but I do not anticipate that to be the case. |
Closing as fixed in ipydatagrid 1.3.1 |
Description
Hey team, we seem to be experiencing an issue where in some specific cases, clicking on the filter icon in an ipydatagrid datagrid, opens the context menu in a really far off position - scrolling to the top of the page. This behaviour is only exhibited when the same notebook is rendered in
voila
.Reproduce
Checkout the gif file below, which shows how to reproduce the behaviour with the following code snippet:
Expected behavior
The context menu should overlap on top of the second grid view - as it does when rendered in JupyterLab or Jupyter Notebook.
Context
The text was updated successfully, but these errors were encountered: