Skip to content

Commit

Permalink
If there's selected text, don't show custom context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Jan 17, 2024
1 parent 3fbd5b8 commit 59d0138
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1271,12 +1271,20 @@ function Status({
}`}
onMouseEnter={debugHover}
onContextMenu={(e) => {
// FIXME: this code isn't getting called on Chrome at all?
if (!showContextMenu) return;
if (e.metaKey) return;
// console.log('context menu', e);
const link = e.target.closest('a');
if (link && /^https?:\/\//.test(link.getAttribute('href'))) return;

// If there's selected text, don't show custom context menu
const selection = window.getSelection?.();
if (selection.toString().length > 0) {
const { anchorNode } = selection;
if (statusRef.current?.contains(anchorNode)) {
return;
}
}
e.preventDefault();
setContextMenuProps({
anchorPoint: {
Expand Down

0 comments on commit 59d0138

Please sign in to comment.