From 71c48bcd476ee2099251b78208ea62fe7b35dcc4 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 11 Jul 2024 08:01:40 -0400 Subject: [PATCH] More possible fixes for #7161 --- app/components/ContextMenu/MenuItem.tsx | 23 ++++++++++++----------- app/editor/components/SuggestionsMenu.tsx | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) 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;