Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: remove replace function when inserting emoji #20149

Merged
merged 2 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,9 +1121,6 @@ const CONST = {
// eslint-disable-next-line no-misleading-character-class
/[\n\s,/?"{}[\]()&^%$#<>!*\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu,

// Define the regular expression pattern to match a string starting with a colon and ending with a space or newline character
EMOJI_REPLACER: /^:[^\n\r]+?(?=$|\s)/,

// Define the regular expression pattern to match a string starting with an at sign and ending with a space or newline character
MENTION_REPLACER:
// eslint-disable-next-line no-misleading-character-class
Expand Down Expand Up @@ -1301,7 +1298,6 @@ const CONST = {

USA_COUNTRY_NAME,
SPACE_LENGTH: 1,
SPACE: 1,

ALL_COUNTRIES: {
AF: 'Afghanistan',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class ReportActionCompose extends React.Component {
const commentBeforeColon = this.state.value.slice(0, this.state.colonIndex);
const emojiObject = this.state.suggestedEmojis[highlightedEmojiIndex];
const emojiCode = emojiObject.types && emojiObject.types[this.props.preferredSkinTone] ? emojiObject.types[this.props.preferredSkinTone] : emojiObject.code;
const commentAfterColonWithEmojiNameRemoved = this.state.value.slice(this.state.selection.end).replace(CONST.REGEX.EMOJI_REPLACER, CONST.SPACE);
const commentAfterColonWithEmojiNameRemoved = this.state.value.slice(this.state.selection.end);

this.updateComment(`${commentBeforeColon}${emojiCode} ${this.trimLeadingSpace(commentAfterColonWithEmojiNameRemoved)}`, true);
// In some Android phones keyboard, the text to search for the emoji is not cleared
Expand Down