diff --git a/app/editor/components/BlockMenu.tsx b/app/editor/components/BlockMenu.tsx index 43207540da..a2fc11772b 100644 --- a/app/editor/components/BlockMenu.tsx +++ b/app/editor/components/BlockMenu.tsx @@ -17,8 +17,7 @@ function BlockMenu(props: Props) { const renderMenuItem = useCallback( (item, _index, options) => ( { const renderMenuItem = useCallback( (item, _index, options) => ( - + ), [] ); diff --git a/app/editor/components/LinkEditor.tsx b/app/editor/components/LinkEditor.tsx index a678dd7a3f..6868f3093b 100644 --- a/app/editor/components/LinkEditor.tsx +++ b/app/editor/components/LinkEditor.tsx @@ -207,7 +207,7 @@ const LinkEditor: React.FC = ({ mark, dictionary, view }) => { <> {results.map((doc, index) => ( { + onPointerDown={() => { updateLink(doc.url); }} onPointerMove={() => setSelectedIndex(index)} diff --git a/app/editor/components/MentionMenu.tsx b/app/editor/components/MentionMenu.tsx index 7865d780aa..95dd4528e7 100644 --- a/app/editor/components/MentionMenu.tsx +++ b/app/editor/components/MentionMenu.tsx @@ -285,8 +285,7 @@ function MentionMenu({ search, isActive, ...rest }: Props) { const renderMenuItem = useCallback( (item, _index, options) => ( { const renderMenuItem = useCallback( (item, _index, options) => ( - + ), [] ); diff --git a/app/editor/components/SuggestionsMenu.tsx b/app/editor/components/SuggestionsMenu.tsx index 98025fd66e..861a73b6c7 100644 --- a/app/editor/components/SuggestionsMenu.tsx +++ b/app/editor/components/SuggestionsMenu.tsx @@ -72,6 +72,7 @@ export type Props = { index: number, options: { selected: boolean; + onPointerDown: (event: React.SyntheticEvent) => void; onClick: (event: React.SyntheticEvent) => void; } ) => React.ReactNode; @@ -641,10 +642,17 @@ function SuggestionsMenu(props: Props) { } }; - const handleOnClick = () => { + const handleOnClick = (ev: React.MouseEvent) => { + ev.preventDefault(); + ev.stopPropagation(); handleClickItem(item); }; + const stopPropagation = (ev: React.MouseEvent) => { + ev.preventDefault(); + ev.stopPropagation(); + }; + const currentHeading = "section" in item ? item.section?.({ t }) : undefined; @@ -661,7 +669,8 @@ function SuggestionsMenu(props: Props) { > {props.renderMenuItem(item as any, index, { selected: index === selectedIndex, - onClick: handleOnClick, + onPointerDown: handleOnClick, + onClick: stopPropagation, })} diff --git a/app/editor/components/SuggestionsMenuItem.tsx b/app/editor/components/SuggestionsMenuItem.tsx index 0ab0832d1d..7f4fe65f4f 100644 --- a/app/editor/components/SuggestionsMenuItem.tsx +++ b/app/editor/components/SuggestionsMenuItem.tsx @@ -15,7 +15,7 @@ export type Props = { /** Whether the item is disabled */ disabled?: boolean; /** Callback when the item is clicked */ - onClick: (event: React.SyntheticEvent) => void; + onPointerDown: (event: React.SyntheticEvent) => void; /** Callback when the item is hovered */ onPointerMove?: (event: React.SyntheticEvent) => void; /** An optional icon for the item */ @@ -31,7 +31,7 @@ export type Props = { function SuggestionsMenuItem({ selected, disabled, - onClick, + onPointerDown, onPointerMove, title, subtitle, @@ -60,7 +60,7 @@ function SuggestionsMenuItem({