From 6da82787577e84db9513a41ffbd38ccf93faed53 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 10 Jun 2025 18:03:48 +0530 Subject: [PATCH 01/13] fix: ComposeBox - When you click on the mention again, extra characters appear. Signed-off-by: krishna2323 --- src/CONST.ts | 6 ++++- .../ReportActionCompose/SuggestionMention.tsx | 23 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 53c4c260e610..31045a65f428 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3604,8 +3604,12 @@ const CONST = { // Define the regular expression pattern to find a potential end of a mention suggestion: // It might be a space, a newline character, an emoji, or a special character (excluding underscores & tildes, which might be used in usernames) + + SPECIAL_CHAR_MENTION_BREAKER: /[,/?"{}[\]()&^%;`$=<>!*]/g, + get MENTION_BREAKER() { - return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR.source}|${this.EMOJI.source}`, 'gu'); + // only break on newline **or** punctuation/emojis — spaces are now allowed in the mention text + return new RegExp(`[\\n]|${this.SPECIAL_CHAR_MENTION_BREAKER.source}|${this.EMOJI.source}`, 'gu'); }, get ALL_EMOJIS() { diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 92bed91f2930..c12cdddd4a15 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -190,6 +190,15 @@ function SuggestionMention( [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 */ @@ -201,7 +210,8 @@ function SuggestionMention( return; } const mentionCode = getMentionCode(mentionObject, suggestionValues.prefixType); - const commentAfterMention = value.slice(suggestionValues.atSignIndex + suggestionValues.mentionPrefix.length + 1); + const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex); + const commentAfterMention = value.slice(suggestionValues.atSignIndex + originalMention.length); updateComment(`${commentBeforeAtSign}${mentionCode} ${trimLeadingSpace(commentAfterMention)}`, true); const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; @@ -216,16 +226,7 @@ function SuggestionMention( shouldShowSuggestionMenu: false, })); }, - [ - value, - suggestionValues.atSignIndex, - suggestionValues.suggestedMentions, - suggestionValues.prefixType, - suggestionValues.mentionPrefix.length, - getMentionCode, - updateComment, - setSelection, - ], + [value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection], ); /** From 0438326958764c0b9a9818a6793c311b72c1efca Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 10 Jun 2025 18:31:48 +0530 Subject: [PATCH 02/13] fix slice length for comment after mention. Signed-off-by: krishna2323 --- src/CONST.ts | 7 +++---- .../home/report/ReportActionCompose/SuggestionMention.tsx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 31045a65f428..369ba5ca5403 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3592,6 +3592,7 @@ const CONST = { HAS_AT_MOST_TWO_AT_SIGNS: /^@[^@]*@?[^@]*$/, EMPTY_COMMENT: /^(\s)*$/, SPECIAL_CHAR: /[,/?"{}[\]()&^%;`$=#<>!*]/g, + SPECIAL_CHAR_MENTION_BREAKER: /[,/?"{}[\]()&^%;`$=<>!*]/g, FIRST_SPACE: /.+?(?=\s)/, get SPECIAL_CHAR_OR_EMOJI() { @@ -3605,11 +3606,9 @@ const CONST = { // Define the regular expression pattern to find a potential end of a mention suggestion: // It might be a space, a newline character, an emoji, or a special character (excluding underscores & tildes, which might be used in usernames) - SPECIAL_CHAR_MENTION_BREAKER: /[,/?"{}[\]()&^%;`$=<>!*]/g, - get MENTION_BREAKER() { - // only break on newline **or** punctuation/emojis — spaces are now allowed in the mention text - return new RegExp(`[\\n]|${this.SPECIAL_CHAR_MENTION_BREAKER.source}|${this.EMOJI.source}`, 'gu'); + // currently breaks on newline **or** whitespace **or** punctuation/emojis + return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR_MENTION_BREAKER.source}|${this.EMOJI.source}`, 'gu'); }, get ALL_EMOJIS() { diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index c12cdddd4a15..a318eb0caad8 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -211,7 +211,7 @@ function SuggestionMention( } 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 + Math.max(originalMention.length, value.length)); updateComment(`${commentBeforeAtSign}${mentionCode} ${trimLeadingSpace(commentAfterMention)}`, true); const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; From 19b6e07683e8d42fd342f8dd18d568ea4e467154 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 10 Jun 2025 18:34:56 +0530 Subject: [PATCH 03/13] fix comment after mention removal. Signed-off-by: krishna2323 --- .../home/report/ReportActionCompose/SuggestionMention.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index a318eb0caad8..58d98b443eab 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -211,7 +211,7 @@ function SuggestionMention( } const mentionCode = getMentionCode(mentionObject, suggestionValues.prefixType); const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex); - const commentAfterMention = value.slice(suggestionValues.atSignIndex + Math.max(originalMention.length, value.length)); + const commentAfterMention = value.slice(suggestionValues.atSignIndex + Math.max(originalMention.length, selection.end ?? 0)); updateComment(`${commentBeforeAtSign}${mentionCode} ${trimLeadingSpace(commentAfterMention)}`, true); const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; @@ -226,7 +226,7 @@ function SuggestionMention( shouldShowSuggestionMenu: false, })); }, - [value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection], + [value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection, selection.end], ); /** From de284a64c9775a3a867d82d844fd367cea2cf437 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Wed, 11 Jun 2025 23:09:47 +0530 Subject: [PATCH 04/13] fix: text after mention is removed. Signed-off-by: krishna2323 --- .../home/report/ReportActionCompose/SuggestionMention.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 58d98b443eab..a83f97d98669 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -211,7 +211,9 @@ function SuggestionMention( } const mentionCode = getMentionCode(mentionObject, suggestionValues.prefixType); const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex); - const commentAfterMention = value.slice(suggestionValues.atSignIndex + Math.max(originalMention.length, selection.end ?? 0)); + const commentAfterMention = value.slice( + suggestionValues.atSignIndex + Math.max(originalMention.length, suggestionValues.mentionPrefix.length + suggestionValues.prefixType.length), + ); updateComment(`${commentBeforeAtSign}${mentionCode} ${trimLeadingSpace(commentAfterMention)}`, true); const selectionPosition = suggestionValues.atSignIndex + mentionCode.length + CONST.SPACE_LENGTH; @@ -226,7 +228,7 @@ function SuggestionMention( shouldShowSuggestionMenu: false, })); }, - [value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection, selection.end], + [value, suggestionValues.atSignIndex, suggestionValues.suggestedMentions, suggestionValues.prefixType, getMentionCode, updateComment, setSelection, suggestionValues.mentionPrefix], ); /** From dbaf185153f5b6f58cd340427f66fa4fe71c0e02 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 13 Jun 2025 00:39:49 +0530 Subject: [PATCH 05/13] fix ESLint. Signed-off-by: krishna2323 --- src/pages/home/report/ReportActionCompose/SuggestionMention.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index a83f97d98669..bbcee41a0364 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -92,7 +92,7 @@ function SuggestionMention( // eslint-disable-next-line react-compiler/react-compiler suggestionValuesRef.current = suggestionValues; - const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: false}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const isMentionSuggestionsMenuVisible = !!suggestionValues.suggestedMentions.length && suggestionValues.shouldShowSuggestionMenu; From 608aa70220ea7a82834c4543652e9b1c608d694f Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 13 Jun 2025 02:29:26 +0530 Subject: [PATCH 06/13] fix text not removed after adding mention by using display name. Signed-off-by: krishna2323 --- src/libs/StringUtils.ts | 9 +++++++++ .../ReportActionCompose/SuggestionMention.tsx | 14 ++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libs/StringUtils.ts b/src/libs/StringUtils.ts index c64d33490b95..97351fdd45c1 100644 --- a/src/libs/StringUtils.ts +++ b/src/libs/StringUtils.ts @@ -137,6 +137,14 @@ function removePreCodeBlock(text = '') { return text.replace(/]*>|<\/pre>/g, ''); } +/** + * Remove white spaces length from the string + */ +function countWhiteSpaces(str: string): number { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + return (str.match(/ /g) || []).length; +} + export default { sanitizeString, isEmptyString, @@ -149,4 +157,5 @@ export default { removeDoubleQuotes, removePreCodeBlock, sortStringArrayByLength, + countWhiteSpaces, }; diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index bbcee41a0364..5e779780f854 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -19,6 +19,7 @@ import {areEmailsFromSamePrivateDomain} from '@libs/LoginUtils'; import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils'; import getPolicyEmployeeAccountIDs from '@libs/PolicyEmployeeListUtils'; import {canReportBeMentionedWithinPolicy, doesReportBelongToWorkspace, getDisplayNameForParticipant, isGroupChat, isReportParticipant} from '@libs/ReportUtils'; +import StringUtils from '@libs/StringUtils'; import {trimLeadingSpace} from '@libs/SuggestionUtils'; import {isValidRoomName} from '@libs/ValidationUtils'; import {searchInServer} from '@userActions/Report'; @@ -190,12 +191,15 @@ function SuggestionMention( [formatLoginPrivateDomain], ); - function getOriginalMentionText(inputValue: string, atSignIndex: number) { + function getOriginalMentionText(inputValue: string, atSignIndex: number, whiteSpacesLength = 0) { const rest = inputValue.slice(atSignIndex); - const breakerIndex = rest.search(CONST.REGEX.MENTION_BREAKER); + if (whiteSpacesLength) { + const str = rest.split(' ', whiteSpacesLength + 1).join(' '); + return rest.slice(0, str.length); + } - // If no breaker is found, return the entire rest of the string + const breakerIndex = rest.search(CONST.REGEX.MENTION_BREAKER); return breakerIndex === -1 ? rest : rest.slice(0, breakerIndex); } @@ -209,8 +213,10 @@ function SuggestionMention( if (!mentionObject || highlightedMentionIndexInner === -1) { return; } + const mentionCode = getMentionCode(mentionObject, suggestionValues.prefixType); - const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex); + const originalMention = getOriginalMentionText(value, suggestionValues.atSignIndex, StringUtils.countWhiteSpaces(suggestionValues.mentionPrefix)); + const commentAfterMention = value.slice( suggestionValues.atSignIndex + Math.max(originalMention.length, suggestionValues.mentionPrefix.length + suggestionValues.prefixType.length), ); From 02c8748d5cf5fa8fe4754ffafe28b364a0f28af2 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 13 Jun 2025 03:39:46 +0530 Subject: [PATCH 07/13] minor fix. Signed-off-by: krishna2323 --- src/libs/StringUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/StringUtils.ts b/src/libs/StringUtils.ts index 9e85a5888d05..62fd81b98f08 100644 --- a/src/libs/StringUtils.ts +++ b/src/libs/StringUtils.ts @@ -145,6 +145,7 @@ function countWhiteSpaces(str: string): number { return (str.match(/ /g) || []).length; } +/** * Hash a string, plus some logic to increase entropy and reduce collisions. * * @param str - the string to generate a whole number hash from From 27e380c76e81122fa8d6e63dfad61cc016fd79ad Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Sun, 15 Jun 2025 05:46:14 +0530 Subject: [PATCH 08/13] add comment. Signed-off-by: krishna2323 --- src/libs/StringUtils.ts | 3 +-- .../home/report/ReportActionCompose/SuggestionMention.tsx | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/StringUtils.ts b/src/libs/StringUtils.ts index 62fd81b98f08..c51a7b4659ac 100644 --- a/src/libs/StringUtils.ts +++ b/src/libs/StringUtils.ts @@ -141,8 +141,7 @@ function removePreCodeBlock(text = '') { * Remove white spaces length from the string */ function countWhiteSpaces(str: string): number { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return (str.match(/ /g) || []).length; + return (str.match(/ /g) ?? []).length; } /** diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index 5e779780f854..edd07eecc5d2 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -194,6 +194,11 @@ function SuggestionMention( function getOriginalMentionText(inputValue: string, atSignIndex: number, whiteSpacesLength = 0) { const rest = inputValue.slice(atSignIndex); + // If the search string contains spaces, it's not a simple login/email mention. + // In that case, we need to replace all the words the user typed that are part of the mention. + // For example, if `rest` is "@Adam Chr asdasda" and "@Adam Chris" is a valid mention, + // then `whiteSpacesLength` will be 1, and we should return "@Adam Chr". + // The length of this substring will then be used to replace the user's input with the full mention. if (whiteSpacesLength) { const str = rest.split(' ', whiteSpacesLength + 1).join(' '); return rest.slice(0, str.length); From 5c78f1a9cd9c61c958bb050bfe1890250d46d82b Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Jun 2025 17:44:01 +0530 Subject: [PATCH 09/13] resolve conflicts. Signed-off-by: krishna2323 --- src/libs/StringUtils.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/libs/StringUtils.ts b/src/libs/StringUtils.ts index c51a7b4659ac..02909e5b1103 100644 --- a/src/libs/StringUtils.ts +++ b/src/libs/StringUtils.ts @@ -137,13 +137,6 @@ function removePreCodeBlock(text = '') { return text.replace(/]*>|<\/pre>/g, ''); } -/** - * Remove white spaces length from the string - */ -function countWhiteSpaces(str: string): number { - return (str.match(/ /g) ?? []).length; -} - /** * Hash a string, plus some logic to increase entropy and reduce collisions. * @@ -189,6 +182,5 @@ export default { removeDoubleQuotes, removePreCodeBlock, sortStringArrayByLength, - countWhiteSpaces, hash, }; From ea7db9514c2f0c22e32f06b3588c4666aad1a77d Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Jun 2025 17:50:32 +0530 Subject: [PATCH 10/13] resolve conflicts. Signed-off-by: krishna2323 --- src/CONST.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 03fdee9e75d6..3b23e2a7314a 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3603,7 +3603,6 @@ const CONST = { HAS_AT_MOST_TWO_AT_SIGNS: /^@[^@]*@?[^@]*$/, EMPTY_COMMENT: /^(\s)*$/, SPECIAL_CHAR: /[,/?"{}[\]()&^%;`$=#<>!*]/g, - SPECIAL_CHAR_MENTION_BREAKER: /[,/?"{}[\]()&^%;`$=<>!*]/g, FIRST_SPACE: /.+?(?=\s)/, get SPECIAL_CHAR_OR_EMOJI() { @@ -3616,10 +3615,8 @@ const CONST = { // Define the regular expression pattern to find a potential end of a mention suggestion: // It might be a space, a newline character, an emoji, or a special character (excluding underscores & tildes, which might be used in usernames) - get MENTION_BREAKER() { - // currently breaks on newline **or** whitespace **or** punctuation/emojis - return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR_MENTION_BREAKER.source}|${this.EMOJI.source}`, 'gu'); + return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR.source}|${this.EMOJI.source}`, 'gu'); }, get ALL_EMOJIS() { From 4801d26bec891778efcf90b7160d968ed176eb9e Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Jun 2025 17:54:35 +0530 Subject: [PATCH 11/13] add changes in new files. Signed-off-by: krishna2323 --- src/CONST/index.ts | 4 +++- src/libs/StringUtils/index.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 9ac5ef673e9a..038b262a237e 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -3598,6 +3598,7 @@ const CONST = { HAS_COLON_ONLY_AT_THE_BEGINNING: /^:[^:]+$/, HAS_AT_MOST_TWO_AT_SIGNS: /^@[^@]*@?[^@]*$/, EMPTY_COMMENT: /^(\s)*$/, + SPECIAL_CHAR_MENTION_BREAKER: /[,/?"{}[\]()&^%;`$=<>!*]/g, SPECIAL_CHAR: /[,/?"{}[\]()&^%;`$=#<>!*]/g, FIRST_SPACE: /.+?(?=\s)/, @@ -3612,7 +3613,8 @@ const CONST = { // Define the regular expression pattern to find a potential end of a mention suggestion: // It might be a space, a newline character, an emoji, or a special character (excluding underscores & tildes, which might be used in usernames) get MENTION_BREAKER() { - return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR.source}|${this.EMOJI.source}`, 'gu'); + // currently breaks on newline **or** whitespace **or** punctuation/emojis + return new RegExp(`[\\n\\s]|${this.SPECIAL_CHAR_MENTION_BREAKER.source}|${this.EMOJI.source}`, 'gu'); }, get ALL_EMOJIS() { diff --git a/src/libs/StringUtils/index.ts b/src/libs/StringUtils/index.ts index 9a36fe3a5f0a..33e5ee81834f 100644 --- a/src/libs/StringUtils/index.ts +++ b/src/libs/StringUtils/index.ts @@ -149,6 +149,13 @@ function getUTF8ByteLength(str: string) { return bytes.length; } +/** + * Remove white spaces length from the string + */ +function countWhiteSpaces(str: string): number { + return (str.match(/ /g) ?? []).length; +} + export default { sanitizeString, isEmptyString, @@ -165,4 +172,5 @@ export default { hash, getUTF8ByteLength, decodeUnicode, + countWhiteSpaces, }; From 9fd6e1a375e7cc2e5b2ed941ea127153bf7d92c2 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 20 Jun 2025 16:45:46 +0530 Subject: [PATCH 12/13] fix spell check. Signed-off-by: krishna2323 --- src/pages/home/report/ReportActionCompose/SuggestionMention.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx index edd07eecc5d2..5267a1e698c5 100644 --- a/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx +++ b/src/pages/home/report/ReportActionCompose/SuggestionMention.tsx @@ -196,7 +196,7 @@ function SuggestionMention( // If the search string contains spaces, it's not a simple login/email mention. // In that case, we need to replace all the words the user typed that are part of the mention. - // For example, if `rest` is "@Adam Chr asdasda" and "@Adam Chris" is a valid mention, + // For example, if `rest` is "@Adam Chr and" and "@Adam Chris" is a valid mention, // then `whiteSpacesLength` will be 1, and we should return "@Adam Chr". // The length of this substring will then be used to replace the user's input with the full mention. if (whiteSpacesLength) { From 9d13cba5360563df6eb8c63f9c4e60e154c9b3ad Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Tue, 24 Jun 2025 15:54:14 +0530 Subject: [PATCH 13/13] minor fix. Signed-off-by: krishna2323 --- src/libs/StringUtils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/StringUtils/index.ts b/src/libs/StringUtils/index.ts index 33e5ee81834f..d6e4e279e0a3 100644 --- a/src/libs/StringUtils/index.ts +++ b/src/libs/StringUtils/index.ts @@ -153,7 +153,7 @@ function getUTF8ByteLength(str: string) { * Remove white spaces length from the string */ function countWhiteSpaces(str: string): number { - return (str.match(/ /g) ?? []).length; + return (str.match(/\s/g) ?? []).length; } export default {