mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
If there's selected text, don't show custom context menu
This commit is contained in:
parent
3fbd5b8622
commit
59d0138ca8
1 changed files with 9 additions and 1 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Reference in a new issue