Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/pages/home/report/ReportActionCompose/SuggestionMention.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
// eslint-disable-next-line react-compiler/react-compiler
suggestionValuesRef.current = suggestionValues;

const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false});
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);

Check failure on line 95 in src/pages/home/report/ReportActionCompose/SuggestionMention.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

useOnyx() calls require you to pass the "canBeMissing" param

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const isMentionSuggestionsMenuVisible = !!suggestionValues.suggestedMentions.length && suggestionValues.shouldShowSuggestionMenu;
Expand Down Expand Up @@ -190,15 +190,6 @@
[formatLoginPrivateDomain],
);

function getOriginalMentionText(inputValue: string, atSignIndex: number) {
const rest = inputValue.slice(atSignIndex);

const breakerIndex = rest.search(CONST.REGEX.MENTION_BREAKER);

// If no breaker is found, return the entire rest of the string
return breakerIndex === -1 ? rest : rest.slice(0, breakerIndex);
}

/**
* Replace the code of mention and update selection
*/
Expand All @@ -210,8 +201,8 @@
return;
}
const mentionCode = getMentionCode(mentionObject, suggestionValues.prefixType);
const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex);
const commentAfterMention = value.slice(suggestionValues.atSignIndex + originalMention.length);
const commentAfterMention = value.slice(suggestionValues.atSignIndex + suggestionValues.mentionPrefix.length + 1);

updateComment(`${commentBeforeAtSign}${mentionCode} ${trimLeadingSpace(commentAfterMention)}`, true);
const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH;
setSelection({
Expand All @@ -225,7 +216,16 @@
shouldShowSuggestionMenu: false,
}));
},
[value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection],
[
value,
suggestionValues.atSignIndex,
suggestionValues.suggestedMentions,
suggestionValues.prefixType,
suggestionValues.mentionPrefix.length,
getMentionCode,
updateComment,
setSelection,
],
);

/**
Expand Down
Loading