Skip to content

Commit

Permalink
Merge pull request #44113 from Expensify/aldo_disable-autocomplete-wh…
Browse files Browse the repository at this point in the history
…en-selecting-block

Disable autocomplete when selecting block
  • Loading branch information
srikarparsi authored Jun 20, 2024
2 parents 1205eda + f431cb7 commit ed50007
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/pages/home/report/ReportActionCompose/SuggestionEmoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -181,7 +181,7 @@ function SuggestionEmoji(
if (!isComposerFocused) {
return;
}
calculateEmojiSuggestion(selection.end);
calculateEmojiSuggestion(selection.start, selection.end);
}, [selection, calculateEmojiSuggestion, isComposerFocused]);

const setShouldBlockSuggestionCalc = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -384,7 +384,7 @@ function SuggestionMention(
);

useEffect(() => {
calculateMentionSuggestion(selection.end);
calculateMentionSuggestion(selection.start, selection.end);
}, [selection, calculateMentionSuggestion]);

useEffect(() => {
Expand Down

0 comments on commit ed50007

Please sign in to comment.