diff --git a/chrome/content/zotero/components/tabBar.jsx b/chrome/content/zotero/components/tabBar.jsx index 568898ef46..69a23eb97a 100644 --- a/chrome/content/zotero/components/tabBar.jsx +++ b/chrome/content/zotero/components/tabBar.jsx @@ -111,15 +111,8 @@ const TabBar = forwardRef(function (props, ref) { function handleTabMouseDown(event, id) { // Don't select tab if it'll be closed with middle button click on mouse up - if (event.button === 1) { - return; - } - if (event.button === 2) { - let { screenX, screenY } = event; - // Popup gets immediately closed without this - setTimeout(() => { - props.onContextMenu(screenX, screenY, id); - }, 0); + // or on right-click + if ([1, 2].includes(event.button)) { return; } @@ -130,6 +123,14 @@ const TabBar = forwardRef(function (props, ref) { event.stopPropagation(); } + function handleContextMenu(event, id) { + let { screenX, screenY } = event; + // Popup gets immediately closed without this + setTimeout(() => { + props.onContextMenu(screenX, screenY, id); + }); + } + function handleTabClick(event, id) { if (event.button === 1) { props.onTabClose(id); @@ -270,6 +271,7 @@ const TabBar = forwardRef(function (props, ref) { className={cx('tab', { selected, dragging: dragging && id === dragIDRef.current })} draggable={true} onMouseDown={(event) => handleTabMouseDown(event, id)} + onContextMenu={(event) => handleContextMenu(event, id)} onClick={(event) => handleTabClick(event, id)} onAuxClick={(event) => handleTabClick(event, id)} onDragStart={(event) => handleDragStart(event, id, index)} diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index 22c26d4e45..48e71383a2 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -718,18 +718,20 @@ class VirtualizedTable extends React.Component { _handleMouseDown = async (e, index) => { const modifierClick = e.shiftKey || e.ctrlKey || e.metaKey; - if (e.button == 2) { - if (!modifierClick && !this.selection.isSelected(index)) { - this._onSelection(index, false, false); - } - this.props.onItemContextMenu(e, e.screenX, e.screenY); - } // All modifier clicks handled in mouseUp per mozilla itemtree convention if (!modifierClick && !this.selection.isSelected(index)) { this._onSelection(index, false, false); } this.focus(); } + + _handleContextMenu = async (e, index) => { + if (!this.selection.isSelected(index)) { + this._onSelection(index, false, false); + } + this.props.onItemContextMenu(e, e.screenX, e.screenY); + this.focus(); + } _handleMouseUp = async (e, index) => { const shiftSelect = e.shiftKey; @@ -1148,6 +1150,7 @@ class VirtualizedTable extends React.Component { node.addEventListener('dragstart', e => this._onDragStart(e, index), { passive: true }); node.addEventListener('dragend', e => this._onDragEnd(e, index), { passive: true }); node.addEventListener('mousedown', e => this._handleMouseDown(e, index), { passive: true }); + node.addEventListener('contextmenu', e => this._handleContextMenu(e, index), { passive: true }); node.addEventListener('mouseup', e => this._handleMouseUp(e, index), { passive: true }); node.addEventListener('dblclick', e => this._activateNode(e, [index]), { passive: true }); }