Skip to content

Commit

Permalink
lint and remove selection compare
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedGaber93 committed Sep 18, 2023
1 parent 124ec28 commit a66f27c
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,16 @@ function ComposerWithSuggestions({
setIsCommentEmpty(!!newComment.match(/^(\s)*$/));
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){
// Reset emoji suggestions when an emoji is replaced.
// Important when emoji is replaced and the selection is not changed, more info issue #27156
if (suggestionsRef.current){
suggestionsRef.current.resetSuggestions();
}

const remainder = ComposerUtils.getCommonSuffixLength(commentRef.current, newComment);
setSelection({
start: newSelectionPosition,
end: newSelectionPosition,
start: newComment.length - remainder,
end: newComment.length - remainder,
});
}

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

/**
Expand Down

0 comments on commit a66f27c

Please sign in to comment.