Skip to content

Commit

Permalink
fix issue 27156
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedGaber93 committed Sep 18, 2023
1 parent 6be8fca commit baa788a
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,17 @@ function ComposerWithSuggestions({
setValue(newComment);
if (commentValue !== newComment) {
const remainder = ComposerUtils.getCommonSuffixLength(commentRef.current, newComment);
const newSelectionPosition = newComment.length - remainder;

// Reset suggestions when an emoji is replaced and the selection is not changed.
// More info issue #27156
if (selection.end === newSelectionPosition){
suggestionsRef.current.resetSuggestions();
}

setSelection({
start: newComment.length - remainder,
end: newComment.length - remainder,
start: newSelectionPosition,
end: newSelectionPosition,
});
}

Expand All @@ -212,7 +220,7 @@ function ComposerWithSuggestions({
debouncedBroadcastUserIsTyping(reportID);
}
},
[debouncedUpdateFrequentlyUsedEmojis, preferredLocale, preferredSkinTone, reportID, setIsCommentEmpty],
[selection.end, debouncedUpdateFrequentlyUsedEmojis, preferredLocale, preferredSkinTone, reportID, setIsCommentEmpty],
);

/**
Expand Down

0 comments on commit baa788a

Please sign in to comment.