Skip to content

Commit

Permalink
[ENG-1791] Fix right-click sometimes opening native context menu (#2637)
Browse files Browse the repository at this point in the history
resolve native context menu opening bug
  • Loading branch information
myung03 authored Jul 26, 2024
1 parent ffa089b commit dd3e647
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion interface/app/$libraryId/Explorer/View/ViewItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, type HTMLAttributes, type PropsWithChildren } from 'react';
import { useCallback, useEffect, type HTMLAttributes, type PropsWithChildren } from 'react';
import {
createSearchParams,
useNavigate,
Expand Down Expand Up @@ -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={
Expand Down

0 comments on commit dd3e647

Please sign in to comment.