[ENG-1791] Fix right-click sometimes opening native context menu (#2637)

resolve native context menu opening bug
This commit is contained in:
Matthew Yung
2024-07-26 05:20:12 -07:00
committed by GitHub
parent 0a179fe825
commit c1801f8929

View File

@@ -1,4 +1,4 @@
import { useCallback, type HTMLAttributes, type PropsWithChildren } from 'react';
import { useCallback, useEffect, type HTMLAttributes, type PropsWithChildren } from 'react';
import {
createSearchParams,
useNavigate,
@@ -215,6 +215,17 @@ export const ViewItem = ({ data, children, ...props }: ViewItemProps) => {
const { doubleClick } = useViewItemDoubleClick();
useEffect(() => {
const handleContextMenu = (e: MouseEvent) => {
e.preventDefault();
};
document.addEventListener('contextmenu', handleContextMenu);
return () => {
document.removeEventListener('contextmenu', handleContextMenu);
};
}, []);
return (
<ContextMenu.Root
trigger={