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-10-10] [$500] Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit #27195

Closed
1 of 6 tasks
kbecciv opened this issue Sep 11, 2023 · 36 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

@kbecciv
Copy link

kbecciv commented Sep 11, 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. Type emoji text in following way: first type 2 colons and then type emoji text like joy, heart in between colons in composer box
  4. Observe that it adds space after emoji
  5. Send any normal message and edit it
  6. Type emoji text in that edit message in similar format as explained in step 3 and observe that it does not add space after emoji

Expected Result:

App should either not add space after emoji in compose box or add space after emoji in edit box to maintain consistency

Actual Result:

App adds space after emoji in compose box and does not add space after emoji in edit box

Workaround:

Unknown

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.3.67.1
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

no.space.after.emoji.in.edit.mp4
Recording.4402.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0195c2171640e5c29b
  • Upwork Job ID: 1701328787879800832
  • Last Price Increase: 2023-09-25
  • Automatic offers:
    • neg-0 | Contributor | 26880380
    • dhanashree-sawant | Reporter | 26880383
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 11, 2023
@melvin-bot melvin-bot bot changed the title Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit [$500] Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0195c2171640e5c29b

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 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

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

melvin-bot bot commented Sep 11, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 11, 2023

Proposal

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

Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit

What is the root cause of that problem?

We are not adding spaces captured by emoji when we are setting selection.

setDraft((prevDraft) => {
if (newDraftInput !== newDraft) {
setSelection((prevSelection) => {
const remainder = prevDraft.slice(prevSelection.end).length;
return {
start: newDraft.length - remainder,
end: newDraft.length - remainder,
};
});
}
return newDraft;
});

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

We need to add spaces captured by emojis with newDraft length and then subtract it.

            setDraft((prevDraft) => {
                if (newDraftInput !== newDraft) {
                    setSelection((prevSelection) => {
                        const remainder = prevDraft.slice(prevSelection.end).length;
                        return {
                            start: newDraft.length + emojis.length - remainder,
                            end: newDraft.length + emojis.length  - remainder,
                        };
                    });
                }
                return newDraft;
            });

Result:

fixed.mp4

@neg-0
Copy link
Contributor

neg-0 commented Sep 11, 2023

Proposal

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

There's an inconsistency between the compose and edit boxes. When typing out an emoji there is sometimes a space after and sometimes not.

What is the root cause of that problem?

There is a difference in the way the selection pointer is calculated in the ReportActionItemMessageEdit editor box vs the ComposerWithSuggestions composer box.

Editor:

setDraft((prevDraft) => {
if (newDraftInput !== newDraft) {
setSelection((prevSelection) => {
const remainder = prevDraft.slice(prevSelection.end).length;
return {
start: newDraft.length - remainder,
end: newDraft.length - remainder,
};
});
}

Composer:

setIsCommentEmpty(!!newComment.match(/^(\s)*$/));
setValue(newComment);
if (commentValue !== newComment) {
const remainder = ComposerUtils.getCommonSuffixLength(commentRef.current, newComment);
setSelection({
start: newComment.length - remainder,
end: newComment.length - remainder,
});
}

Note the Composer uses the ComposerUtils.getCommonSuffixLength to calculate the cursor position.

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

By utilizing the same ComposerUtils.getCommonSuffixLength function inside of the editor box, the cursor position is calculated correctly.

image

Recording.2023-09-11.174251.mp4

What alternative solutions did you explore? (Optional)

We could also create a separate helper function so that we do not use "composer" utils alongside an editor component, however, it would be a duplication of code.

@trjExpensify
Copy link
Contributor

I was assigned second, dropping off.

@neg-0
Copy link
Contributor

neg-0 commented Sep 11, 2023

@Krishna2323 I tried your code but it seems to set the cursor to the wrong position if you insert an emoji in the middle of text while editing, depending on if you "complete" the emoji either inside or outside of the colons.

Recording.2023-09-11.180706.mp4

@Krishna2323
Copy link
Contributor

@neg-0, yes you are correct, my solution is not correct.

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Sep 14, 2023

first type 2 colons and then type emoji text like joy,
does anyone actually do this? I always type one : then add text. Otherwise, if you try to put beer inside of the : you get this

image cuz, once you have `:b:` it adds the emoji.

And.. when adding emoji via one : in the compose box and when editing, it's consistent when adding a space after

2023-09-14_14-27-31.mp4

@neg-0
Copy link
Contributor

neg-0 commented Sep 15, 2023

@mallenexpensify You're right! Fortunately the helper function from ComposerUtils works in all cases!

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@eVoloshchak
Copy link
Contributor

Reviewing this tomorrow as a first priority

@melvin-bot melvin-bot bot removed the Overdue label Sep 18, 2023
@eVoloshchak
Copy link
Contributor

I think we should proceed with @neg-0's proposal

We could also create a separate helper function so that we do not use "composer" utils alongside an editor component, however, it would be a duplication of code.

I agree that would be redundant, ideally we should use a single method for both of these (which is exactly what this proposal achieves)

🎀👀🎀 C+ reviewed!

@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

📣 @dhanashree-sawant 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 27, 2023
@neg-0
Copy link
Contributor

neg-0 commented Sep 27, 2023

@eVoloshchak @youssef-lr PR has been submitted! #28297

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @neg-0 got assigned: 2023-09-26 09:34:54 Z
  • when the PR got merged: 2023-10-02 09:56:08 UTC
  • days elapsed: 4

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 3, 2023
@melvin-bot melvin-bot bot changed the title [$500] Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit [HOLD for payment 2023-10-10] [$500] Web - Inconsistency bug: App adds space after emoji in composer box but does not add space after emoji in edit Oct 3, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.76-6 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-10-10. 🎊

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

For reference, here are some details about the assignees on this issue:

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 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:

  • [@eVoloshchak] The PR that introduced the bug has been identified. Link to the PR:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] 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:
  • [@eVoloshchak] Determine if we should create a regression test for this bug.
  • [@eVoloshchak] 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.
  • [@mallenexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@eVoloshchak
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: Improved selection placement when emoji is typed #22827
  • 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: https://github.com/Expensify/App/pull/22827/files#r1355100751
  • 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: we already have an item in reviewer checklist to catch this (If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic), this was just a case that was missed during implementation
  • Determine if we should create a regression test for this bug.
    This is a very minor bug, an edge case that a few users would have ever encountered. In addition to that, it doesn't prevent users from using the app. I don't think a regression test is needed here

@melvin-bot melvin-bot bot added the Overdue label Oct 16, 2023
@eVoloshchak
Copy link
Contributor

Requested the $500 payment via NewDot

@melvin-bot melvin-bot bot removed the Overdue label Oct 16, 2023
@mallenexpensify
Copy link
Contributor

Issue reporter: @dhanashree-sawant paid $50 via Upwork
Contributor: @neg-0 paid $500 via Upwork
Contributor+: @eVoloshchak due $500 via NewDot

@eVoloshchak err on the side of proposing to create regression tests because QA/Applause keeps a separate doc/list of edge cases they check once a month. Thx

@JmillsExpensify
Copy link

$500 payment approved for @eVoloshchak based on summary above.

@eVoloshchak
Copy link
Contributor

Regression Test Proposal

  1. Open the app
  2. Open any report
  3. Type an emoji text in the following way: first type 2 colons and then type emoji text like joy, heart in between colons in the composer box (i.e. :joy:)
  4. Verify that the space is added after the emoji
  5. Send any normal message and edit it
  6. While editing, type an emoji in similar format as explained in step 3
  7. Verify that the space is added after the emoji

Do we agree 👍 or 👎

@JmillsExpensify
Copy link

Re-opening for the regression test.

@mallenexpensify
Copy link
Contributor

mallenexpensify commented Oct 17, 2023

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

8 participants