From b4bbd4c76a20b9902236c17ac80a1a70a2365394 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Fri, 13 Oct 2023 06:24:34 -0600 Subject: [PATCH 1/3] Hide suggestions only if we inserted an emoji Signed-off-by: Pierre Michel --- .../report/ReportActionCompose/ComposerWithSuggestions.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js index faa710d2cd6b..5d3d34cc9f53 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js @@ -206,6 +206,7 @@ function ComposerWithSuggestions({ if (!_.isEmpty(emojis)) { const newEmojis = EmojiUtils.getAddedEmojis(emojis, emojisPresentBefore.current); if (!_.isEmpty(newEmojis)) { + suggestionsRef.current.resetSuggestions(); insertedEmojisRef.current = [...insertedEmojisRef.current, ...newEmojis]; debouncedUpdateFrequentlyUsedEmojis(); } @@ -214,10 +215,6 @@ function ComposerWithSuggestions({ setIsCommentEmpty(!!newComment.match(/^(\s)*$/)); setValue(newComment); if (commentValue !== newComment) { - // Ensure emoji suggestions are hidden even when the selection is not changed (so calculateEmojiSuggestion would not be called). - if (suggestionsRef.current) { - suggestionsRef.current.resetSuggestions(); - } const remainder = ComposerUtils.getCommonSuffixLength(commentValue, newComment); setSelection({ From 34d0a51e6d302abe5619d6332edaf6b7116746c4 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Tue, 17 Oct 2023 06:19:53 -0600 Subject: [PATCH 2/3] Adding null check and run prettier Signed-off-by: Pierre Michel --- .../report/ReportActionCompose/ComposerWithSuggestions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js index 5d3d34cc9f53..8232336fc7ef 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js @@ -206,7 +206,9 @@ function ComposerWithSuggestions({ if (!_.isEmpty(emojis)) { const newEmojis = EmojiUtils.getAddedEmojis(emojis, emojisPresentBefore.current); if (!_.isEmpty(newEmojis)) { - suggestionsRef.current.resetSuggestions(); + if (suggestionsRef.current) { + suggestionsRef.current.resetSuggestions(); + } insertedEmojisRef.current = [...insertedEmojisRef.current, ...newEmojis]; debouncedUpdateFrequentlyUsedEmojis(); } @@ -215,7 +217,6 @@ function ComposerWithSuggestions({ setIsCommentEmpty(!!newComment.match(/^(\s)*$/)); setValue(newComment); if (commentValue !== newComment) { - const remainder = ComposerUtils.getCommonSuffixLength(commentValue, newComment); setSelection({ start: newComment.length - remainder, From fb05f35f0172d83c7f9d02873cbce33c0f982c91 Mon Sep 17 00:00:00 2001 From: Pierre Michel Date: Tue, 17 Oct 2023 06:27:04 -0600 Subject: [PATCH 3/3] Adding a comment Signed-off-by: Pierre Michel --- .../home/report/ReportActionCompose/ComposerWithSuggestions.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js index 8232336fc7ef..4ac6eee83806 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js @@ -206,6 +206,7 @@ function ComposerWithSuggestions({ if (!_.isEmpty(emojis)) { const newEmojis = EmojiUtils.getAddedEmojis(emojis, emojisPresentBefore.current); if (!_.isEmpty(newEmojis)) { + // Ensure emoji suggestions are hidden after inserting emoji even when the selection is not changed if (suggestionsRef.current) { suggestionsRef.current.resetSuggestions(); }