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( 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(() => {