From 2e184c679786bda8f428ae3f58d7e0729a162784 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Thu, 20 Jun 2024 12:26:18 -0700 Subject: [PATCH 1/2] Disable mention suggestion box if selecting text --- .../home/report/ReportActionCompose/SuggestionMention.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 0b430a519812..129c8c822d74 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -317,8 +317,8 @@ function SuggestionMention( ); const calculateMentionSuggestion = useCallback( - (selectionEnd?: number) => { - if (!selectionEnd || shouldBlockCalc.current || selectionEnd < 1 || !isComposerFocused) { + (selectionStart?: number, selectionEnd?: number) => { + if (selectionEnd !== selectionStart || !selectionEnd || shouldBlockCalc.current || selectionEnd < 1 || !isComposerFocused) { shouldBlockCalc.current = false; resetSuggestions(); return; @@ -384,7 +384,7 @@ function SuggestionMention( ); useEffect(() => { - calculateMentionSuggestion(selection.end); + calculateMentionSuggestion(selection.start, selection.end); }, [selection, calculateMentionSuggestion]); useEffect(() => { From f431cb709ec59b72a349b9f8be7d0dbb3b4f51d5 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Thu, 20 Jun 2024 12:28:04 -0700 Subject: [PATCH 2/2] Disable emoji suggestion box if selecting text --- .../home/report/ReportActionCompose/SuggestionEmoji.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx index b08ee77745db..9b04fd7df4dc 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx @@ -149,8 +149,8 @@ function SuggestionEmoji( * Calculates and cares about the content of an Emoji Suggester */ const calculateEmojiSuggestion = useCallback( - (selectionEnd?: number) => { - if (!selectionEnd || shouldBlockCalc.current || !value) { + (selectionStart?: number, selectionEnd?: number) => { + if (selectionStart !== selectionEnd || !selectionEnd || shouldBlockCalc.current || !value) { shouldBlockCalc.current = false; resetSuggestions(); return; @@ -181,7 +181,7 @@ function SuggestionEmoji( if (!isComposerFocused) { return; } - calculateEmojiSuggestion(selection.end); + calculateEmojiSuggestion(selection.start, selection.end); }, [selection, calculateEmojiSuggestion, isComposerFocused]); const setShouldBlockSuggestionCalc = useCallback(