From 1714351cc9624e5e3755d5934e9103671476e810 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 4 May 2022 05:45:37 -0400 Subject: [PATCH] fx-compat: Fix position of collection and item context menus --- .../zotero/components/virtualized-table.jsx | 8 ++++++-- chrome/content/zotero/zoteroPane.js | 14 ++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index 40fa84d14c..9fbe64bad8 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -577,7 +577,11 @@ class VirtualizedTable extends React.Component { if (e.key == 'ContextMenu' || (e.key == 'F10' && e.shiftKey)) { let selectedElem = document.querySelector(`#${this._jsWindowID} [aria-selected=true]`); let boundingRect = selectedElem.getBoundingClientRect(); - this.props.onItemContextMenu(e, boundingRect.left + 50, boundingRect.bottom); + this.props.onItemContextMenu( + e, + window.screenX + boundingRect.left + 50, + window.screenY + boundingRect.bottom + ); return; } @@ -670,7 +674,7 @@ class VirtualizedTable extends React.Component { if (!modifierClick && !this.selection.isSelected(index)) { this._onSelection(index, false, false); } - this.props.onItemContextMenu(e, e.clientX, e.clientY); + this.props.onItemContextMenu(e, window.screenX + e.clientX, window.screenY + e.clientY); } // All modifier clicks handled in mouseUp per mozilla itemtree convention if (!modifierClick && !this.selection.isSelected(index)) { diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 2f37787eaf..3168856bde 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2662,10 +2662,9 @@ var ZoteroPane = new function() */ this.onCollectionsContextMenuOpen = async function (event, x, y) { await ZoteroPane.buildCollectionContextMenu(); - x = x || event.clientX; - y = y || event.clientY; - document.getElementById('zotero-collectionmenu').openPopup( - null, null, x + 1, y + 1); + x = x || event.screenX; + y = y || event.screenY; + document.getElementById('zotero-collectionmenu').openPopupAtScreen(x + 1, y + 1, true); }; @@ -2674,10 +2673,9 @@ var ZoteroPane = new function() */ this.onItemsContextMenuOpen = async function (event, x, y) { await ZoteroPane.buildItemContextMenu(); - x = x || event.clientX; - y = y || event.clientY; - document.getElementById('zotero-itemmenu').openPopup( - null, null, x + 1, y + 1); + x = x || event.screenX; + y = y || event.screenY; + document.getElementById('zotero-itemmenu').openPopupAtScreen(x + 1, y + 1, true); };