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

[HOLD for payment 2023-05-02] [$2000] Spacing between emojis reduced when editing a message with emojis #15951

Closed
6 tasks done
kavimuru opened this issue Mar 14, 2023 · 74 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kavimuru
Copy link

kavimuru commented Mar 14, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Open any report
  3. Tap/click on the emoji icon, and then tap/click on any emoji in the emoji picker dialog
  4. Notice how a space is added after the emoji (this shouldn't happen)
  5. Send the message
  6. Tap/click the button to update the message
  7. Tap/click on the emoji icon, and then tap/click on any emoji in the emoji picker dialog
  8. Notice how no space is added after the emoji (this is expected)

Expected Result:

When tapping/clicking the emoji icon and then tapping/clicking the emoji in the emoji picker dialog, no space should be added after the emoji

Actual Result:

When tapping/clicking the emoji icon and then tapping/clicking the emoji in the emoji picker dialog, a space is added after the emoji

Workaround:

n/a

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.2.83-0
Reproducible in staging?: y
Reproducible in production?: y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:

emoji.spacing.issue.mac.mov
Recording.1700.mp4

Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1678792710814599

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0136a41936e77380dc
  • Upwork Job ID: 1636101649624674304
  • Last Price Increase: 2023-04-05
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 14, 2023
@melvin-bot melvin-bot bot locked and limited conversation to collaborators Mar 14, 2023
@MelvinBot
Copy link

Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@MelvinBot
Copy link

MelvinBot commented Mar 14, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@sakluger
Copy link
Contributor

Looks good, adding External label.

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Mar 15, 2023
@melvin-bot melvin-bot bot unlocked this conversation Mar 15, 2023
@melvin-bot melvin-bot bot changed the title Spacing between emojis reduced when editing a message with emojis [$1000] Spacing between emojis reduced when editing a message with emojis Mar 15, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~0136a41936e77380dc

@MelvinBot
Copy link

Current assignee @sakluger is eligible for the External assigner, not assigning anyone new.

@MelvinBot
Copy link

Triggered auto assignment to Contributor-plus team member for initial proposal review - @Santhosh-Sellavel (External)

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 15, 2023
@tienifr
Copy link
Contributor

tienifr commented Mar 15, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

When tapping/clicking the emoji icon and then tapping/clicking the emoji in the emoji picker dialog, a space is added after the emoji

What is the root cause of that problem?

In our implementation, we are adding a space after emoji in the main composer

addEmojiToTextBox(emoji) {
const emojiWithSpace = `${emoji} `;

What changes do you think we should make in order to solve the problem?

we should put this code


        const newComment = this.comment.slice(0, this.state.selection.start)
            + emojiWithSpace
            + this.comment.slice(this.state.selection.end, this.comment.length);

into the utils function ReportUtils like this

function addEmoji(emoji, selection, comment, update) {

    const newComment = comment.slice(0, selection.start)
            + emoji
            + comment.slice(selection.end, comment.length);
    update(newcomment)
}

and using it in App/src/pages/home/report/ReportActionItemMessageEdit.js

addEmojiToTextBox(emoji) {
    
        ReportUtils.addEmoji(emoji, this.state.selection, this.state.draft, this.updateDraft)
        this.setState(prevState => ({
            selection: {
                start: prevState.selection.start + emoji.length,
                end: prevState.selection.start + emoji.length,
            },
        }));
    }

Do the same thing in the App/src/pages/home/report/ReportActionCompose.js

What alternative solutions did you explore? (Optional)

Or we can remove the space in the main composer directly

In here:

addEmojiToTextBox(emoji) {
const emojiWithSpace = `${emoji} `;

remove this line

 const emojiWithSpace = `${emoji} `;

@MelvinBot
Copy link

Triggered auto assignment to @cead22 (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@CodeTheEd
Copy link

CodeTheEd commented Mar 15, 2023

Proposal
Please re-state the problem that we are trying to solve in this issue.
Spacing between emojis reduced when editing a message with emojis

What is the root cause of that problem?

When you send emoji there was a bit space but when add emoji on edit there was not space after emoji

What changes do you think we should make in order to solve the problem?

there was space that was adding after sending emoji remove the space after closing bracket this {emoji}
Space in pic
Screenshot_9

Code:
addEmojiToTextBox(emoji) {
Erroe Line 456:

const emojiWithSpace = ${emoji} ;
const newComment = this.comment.slice(0, this.state.selection.start)
+ emojiWithSpace
+ this.comment.slice(this.state.selection.end, this.comment.length);
this.setState(prevState => ({
selection: {
start: prevState.selection.start + emojiWithSpace.length,
end: prevState.selection.start + emojiWithSpace.length,
},
}));
this.updateComment(newComment);
}

Correct Line:
correct line: const emojiWithSpace = ${emoji}`;```
Result:
https://user-images.githubusercontent.com/127790689/225440964-73e292ef-c3da-4bc0-acbb-291bbf9494dc.mp4

@MelvinBot
Copy link

📣 @CodeTheEd! 📣

Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.

Screen Shot 2022-11-16 at 4 42 54 PM

Format:

Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Karim-30
Copy link
Contributor

Karim-30 commented Mar 15, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

When adding an emoji inside the Composer, an empty space is added after it, but when editing messages, the empty space is not added.

What is the root cause of that problem?

Inside addEmojiToTextBox there is an empty space added after the emoji

  addEmojiToTextBox(emoji) {
        const emojiWithSpace = `${emoji} `;

but this not happens when editing messages

addEmojiToTextBox(emoji) {
         const newComment = this.state.draft.slice(0, this.state.selection.start)
            + emoji + this.state.draft.slice(this.state.selection.end, this.state.draft.length);

What changes do you think we should make in order to solve the problem?

  1. Add addEmojiToTextBox function to EmojiUtils file.
/**
 * Add an emoji to the text inside the Composer when selected from the emoji picker
 *
 * @param {String} emoji
 * @param {String} comment
 * @param {Object} selection
 * @param {Function} cb
 */
const addEmojiToTextBox = (emoji, comment, selection, cb) => {
    const emojiWithSpace = `${emoji} `;
    const newComment = comment.slice(0, selection.start)
        + emojiWithSpace
        + comment.slice(selection.end, comment.length);
    cb(newComment, emojiWithSpace);
};

export {
    getHeaderEmojis,
    mergeEmojisWithFrequentlyUsedEmojis,
    addToFrequentlyUsedEmojis,
    containsOnlyEmojis,
    replaceEmojis,
    suggestEmojis,
    trimEmojiUnicode,
    getEmojiCodeWithSkinColor,
    addEmojiToTextBox,
};
  1. Remove addEmojiToTextBox and its bind from both ReportActionCompose and ReportActionMessageEdit
  2. Call addEmojiToTextBox function inside onEmojiSelected callback in both ReportActionCompose and ReportActionMessageEdit.
                        <EmojiPickerButton
                            isDisabled={isBlockedFromConcierge || this.props.disabled}
                            onModalHide={() => this.focus(true)}
                            onEmojiSelected={(emoji) => {
                                EmojiUtils.addEmojiToTextBox(emoji, this.comment, this.state.selection, (newComment, emojiWithSpace) => {
                                    this.setState(prevState => ({
                                        selection: {
                                            start: prevState.selection.start + emojiWithSpace.length,
                                            end: prevState.selection.start + emojiWithSpace.length,
                                        },
                                    }));
                                    this.updateComment(newComment);
                                });
                            }}
                        />
                        <EmojiPickerButton
                            isDisabled={this.props.shouldDisableEmojiPicker}
                            onModalHide={() => InteractionManager.runAfterInteractions(() => this.textInput.focus())}
                            onEmojiSelected={(emoji) => {
                                EmojiUtils.addEmojiToTextBox(emoji, this.state.draft, this.state.selection, (newComment, emojiWithSpace) => {
                                    this.setState(prevState => ({
                                        selection: {
                                            start: prevState.selection.start + emojiWithSpace.length,
                                            end: prevState.selection.start + emojiWithSpace.length,
                                        },
                                    }));
                                    this.updateDraft(newComment);
                                });
                            }}
                            nativeID={this.emojiButtonID}
                        />

Also, there is a use case when editing a message that ends with an emoji, in default when sending a message ends with an emoji the empty space will be trimmed, so we need to add it manually when the user tries to edit a message that ends with an emoji.

draftMessage inside ReportActionItemMessageEdit.js will be :

const parser = new ExpensiMark();
        let draftMessage = parser.htmlToMarkdown(this.props.draftMessage);

        // eslint-disable-next-line no-misleading-character-class
        if (draftMessage.match(/[\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]$|[#*0-9]\uFE0F?\u20E3$/gu)) {
            draftMessage += ' ';
        }

What alternative solutions did you explore? (Optional)

@MelvinBot
Copy link

📣 @Karim-30! 📣

Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  2. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  3. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.

Screen Shot 2022-11-16 at 4 42 54 PM

Format:

Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@MelvinBot
Copy link

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@bernhardoj
Copy link
Contributor

bernhardoj commented Mar 16, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

There is no space when we add an emoji in edit composer.

What is the root cause of that problem?

The space is not added after we add an emoji for this issue #13343. This should apply to both main and edit composer. However, one of the commits of this PR #14686 accidentaly "reverted" it for main composer, so there is a space added after inserting an emoji.

What changes do you think we should make in order to solve the problem?

We should reapply what this PR #13875 done, which is to not add a space after inserting an emoji for ReportActionCompose, otherwise we will make a regression of this issue #13343.

https://github.com/Expensify/App/pull/13875/files#diff-c5849fa15c0bb6fc9018f71893e9e91f84308a529b725716ad6d6f0d06ef4089R185-R191

And based on the latest suggestion, we can create a common function to unify the logic inside ReportUtils. The logic is taken from the edit composer.

insertEmoji(text, selection, emoji) {
  return text.slice(0, selection.start) + emoji + text.slice(selection.end, text.length);
}

and use it in both main and edit composer.

    addEmojiToTextBox(emoji) {
        this.setState(prevState => ({
            selection: {
                start: prevState.selection.start + emoji.length,
                end: prevState.selection.start + emoji.length,
            },
        }));
        this.updateComment(ReportUtils.insertEmoji(this.comment, this.state.selection, emoji));
    }

@melvin-bot melvin-bot bot added the Overdue label Mar 20, 2023
@Santhosh-Sellavel
Copy link
Collaborator

@cead22 What's the expected behavior can you confirm this?

@melvin-bot melvin-bot bot removed the Overdue label Mar 20, 2023
@Snehal-Techforce
Copy link

Proposal

Please re-state the problem that we are trying to solve in this issue:

When editing a message with emojis, there are no spacing after emojis like in the main composer

What is the root cause of that problem:

Here 2 variables are used to store the draft & edited emojis in chat. 1. emoji 2. draft

  1. Missing extra space before emoji variable in addEmojiToTextBox function in ReportActionItemMessageEdit.js file

  2. Missing extra space before draft variable in updateDraft function in ReportActionItemMessageEdit.js file

Screenshot 2023-03-22 at 8 07 00 PM

Screenshot 2023-03-22 at 7 46 29 PM

What changes do you think we should make in order to solve the problem:

To resolve the spacing issue between edited emoji messages, the solution below can be applied.

  1. Add space before the emoji variable in addEmojiToTextBox function in ReportActionItemMessageEdit.js file ( line no: 202 )

  2. Add space before the draft variable in addEmojiToTextBox function in ReportActionItemMessageEdit.js file ( line no: 117 )

Screenshot 2023-03-22 at 8 07 46 PM

Screenshot 2023-03-22 at 8 08 00 PM

What alternative solutions did you explore:

NA

Expected Output:

Screenshot 2023-03-22 at 7 36 08 PM

@MelvinBot
Copy link

@cead22, @sakluger, @bernhardoj, @Santhosh-Sellavel Whoops! This issue is 2 days overdue. Let's get this updated quick!

@MelvinBot
Copy link

@cead22, @sakluger, @bernhardoj, @Santhosh-Sellavel Still overdue 6 days?! Let's take care of this!

@Santhosh-Sellavel
Copy link
Collaborator

All good here just waiting for deployment!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Apr 25, 2023
@melvin-bot melvin-bot bot changed the title [$2000] Spacing between emojis reduced when editing a message with emojis [HOLD for payment 2023-05-02] [$2000] Spacing between emojis reduced when editing a message with emojis Apr 25, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Apr 25, 2023
@MelvinBot
Copy link

Reviewing label has been removed, please complete the "BugZero Checklist".

@MelvinBot
Copy link

MelvinBot commented Apr 25, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.4-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-05-02. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@MelvinBot
Copy link

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@Santhosh-Sellavel] The PR that introduced the bug has been identified. Link to the PR:
  • [@Santhosh-Sellavel] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@Santhosh-Sellavel] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@sakluger] Determine if we should create a regression test for this bug.
  • [@Santhosh-Sellavel] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added the Overdue label May 3, 2023
@Santhosh-Sellavel
Copy link
Collaborator

Not overdue

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented May 3, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

@cead22 Do you differ from any of the above let me know

@Santhosh-Sellavel
Copy link
Collaborator

@cead22 @sakluger

The steps for the PR here look good to me.

Regression Steps

  1. Open any chat
  2. Press the emoji picker button on the main composer
  3. Pick any emoji
  4. Verify the emoji added to the main composer without additional space
  5. Send a message
  6. Edit the message
  7. Press the emoji picker button on the edit composer
  8. Pick any emoji
  9. Verify the emoji added to the edit composer without additional space

👍 or 👎

@dhanashree-sawant
Copy link

Hi @sakluger , @cead22 , @Santhosh-Sellavel , ping for payment.

@sakluger sakluger added Daily KSv2 and removed Weekly KSv2 labels May 11, 2023
@sakluger
Copy link
Contributor

Sorry for the delay! Just sent offers to everyone, I'll check back tomorrow to pay.

@sakluger
Copy link
Contributor

Hey @Santhosh-Sellavel, I'm trying to understand what you meant by the following regarding regressions steps on the bugzero checklist:

A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: Not needed I guess, it should have caught based on the checklist.

Does that mean that we already have regression steps for this?

@Santhosh-Sellavel
Copy link
Collaborator

@sakluger It's not about wanting regression steps, it's about updating the PR review checklist.

@Santhosh-Sellavel
Copy link
Collaborator

Santhosh-Sellavel commented May 11, 2023

I think we need regression test steps. Here are the steps

@sakluger
Copy link
Contributor

Got it got it, my bad!

@sakluger
Copy link
Contributor

All paid out 👍
Regression test GH issue created: https://github.com/Expensify/Expensify/issues/283035

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests