Skip to content

Commit

Permalink
Merge pull request #29711 from ShogunFire/hideEmojiSuggestionsWhenEmo…
Browse files Browse the repository at this point in the history
…jiInserted

Hide suggestions only if we inserted an emoji
  • Loading branch information
Li357 authored Oct 17, 2023
2 parents b494186 + fb05f35 commit 700d214
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ 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();
}
insertedEmojisRef.current = [...insertedEmojisRef.current, ...newEmojis];
debouncedUpdateFrequentlyUsedEmojis();
}
Expand All @@ -224,11 +228,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({
start: newComment.length - remainder,
Expand Down

0 comments on commit 700d214

Please sign in to comment.