diff --git a/app/components/ContextMenu/MenuItem.tsx b/app/components/ContextMenu/MenuItem.tsx index fcc91d070e..939f84f87b 100644 --- a/app/components/ContextMenu/MenuItem.tsx +++ b/app/components/ContextMenu/MenuItem.tsx @@ -11,7 +11,7 @@ import MenuIconWrapper from "./MenuIconWrapper"; type Props = { id?: string; - onClick?: (event: React.SyntheticEvent) => void | Promise; + onClick?: (event: React.MouseEvent) => void | Promise; active?: boolean; selected?: boolean; disabled?: boolean; @@ -43,30 +43,31 @@ const MenuItem = ( ) => { const content = React.useCallback( (props) => { + // Preventing default mousedown otherwise menu items do not work in Firefox, + // which triggers the hideOnClickOutside handler first via mousedown – hiding + // and un-rendering the menu contents. + const preventDefault = (ev: React.MouseEvent) => { + ev.preventDefault(); + ev.stopPropagation(); + }; + const handleClick = async (ev: React.MouseEvent) => { hide?.(); if (onClick) { - ev.preventDefault(); + preventDefault(ev); await onClick(ev); } }; - // Preventing default mousedown otherwise menu items do not work in Firefox, - // which triggers the hideOnClickOutside handler first via mousedown – hiding - // and un-rendering the menu contents. - const handleMouseDown = (ev: React.MouseEvent) => { - ev.preventDefault(); - ev.stopPropagation(); - }; - return ( , diff --git a/app/editor/components/SuggestionsMenu.tsx b/app/editor/components/SuggestionsMenu.tsx index bda4723b37..868c16450d 100644 --- a/app/editor/components/SuggestionsMenu.tsx +++ b/app/editor/components/SuggestionsMenu.tsx @@ -67,7 +67,7 @@ export type Props = { index: number, options: { selected: boolean; - onClick: () => void; + onClick: (event: React.SyntheticEvent) => void; } ) => React.ReactNode; filterable?: boolean;