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 app #12854] [$2000] Shows incorrect emoji while combining the manual and emoji picker selected emoji within the text #13066

Closed
kavimuru opened this issue Nov 27, 2022 · 138 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Monthly KSv2

Comments

@kavimuru
Copy link

kavimuru commented Nov 27, 2022

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Load new.expensify.com.
  2. Open a chat.
  3. type Te:smile :st in the text bar.
  4. remove the space so the smile emoji renders inside of the word test. leave your cursor flush with the emoji.
  5. click the emoji picker.
  6. select an emoji.
  7. confirm that the new emoji loads in between the two question mark characters. This is the bug.

Expected Result:

Should show both emoji adjacently after selecting the second one.

Actual Result:

Shows a weird emoji, and removes the original emoji, incorrectly.

Workaround:

Select emojis via the emoji picker.

Platform:

Where is this issue occurring?

  • Web

Version Number: v1.2.32-1
Reproducible in staging?: y
Reproducible in production?: y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:
7c67d298-274a-4ea8-a781-e28384f08007.webm
https://user-images.githubusercontent.com/43996225/204145304-bf1f2078-3b3f-46c5-9ac0-26b4d8bcf01e.mp4

Expensify/Expensify Issue URL:
Issue reported by: @Pujan92
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1669391872652859

View all open jobs on GitHub

Recording.1012.mp4
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016d120322c0f448f0
  • Upwork Job ID: 1597336781605519360
  • Last Price Increase: 2023-04-17
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016d120322c0f448f0
  • Upwork Job ID: 1597336781605519360
  • Last Price Increase: 2023-04-17
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 27, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 27, 2022

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

@Pujan92
Copy link
Contributor

Pujan92 commented Nov 27, 2022

Proposal

As we are removing the character between the emoji string(: smile:) I think prevState selection logic won't work in the following code.

const remainder = prevState.value.slice(prevState.selection.end).length;
newState.selection = {
start: newComment.length - remainder,
end: newComment.length - remainder,
};

const index = this.getLastUnmatchedCharacterIndex(comment, newComment) + 1;
newState.selection = {
    start: index,
    end: index,
};

getLastUnmatchedCharacterIndex(text, modifiedText) {
    for (let i = text.length - 1, j = modifiedText.length - 1; i >= 0; i--, j--) {
        if (text[i] !== modifiedText[j]) {
             return j;
         }
     }
}

The above solution will fix 12325 too which was earlier fixed with prevState selection logic.

@s77rt
Copy link
Contributor

s77rt commented Nov 27, 2022

Proposal

diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js
index 2335864f91..fc7b5fad51 100644
--- a/src/pages/home/report/ReportActionCompose.js
+++ b/src/pages/home/report/ReportActionCompose.js
@@ -7,6 +7,7 @@ import {
 } from 'react-native';
 import _ from 'underscore';
 import lodashGet from 'lodash/get';
+import lodashClamp from 'lodash/clamp';
 import {withOnyx} from 'react-native-onyx';
 import lodashIntersection from 'lodash/intersection';
 import styles from '../../../styles/styles';
@@ -389,10 +390,11 @@ class ReportActionCompose extends React.Component {
                 value: newComment,
             };
             if (comment !== newComment) {
-                const remainder = prevState.value.slice(prevState.selection.end).length;
+                const offset = newComment.length - comment.length;
+                const compensation = Math.max(comment.length - prevState.value.length, 0);
                 newState.selection = {
-                    start: newComment.length - remainder,
-                    end: newComment.length - remainder,
+                    start: lodashClamp(prevState.selection.start + offset + compensation, 0, newComment.length),
+                    end: lodashClamp(prevState.selection.end + offset + compensation, 0, newComment.length),
                 };
             }
             return newState;

Details:

The current implemented code does not take into account compensation and overflow.
In my proposal I added a compensation variable to fix the current issue and used lodashClamp to cover other cases (e.g. write : wave:hi then remove the space before wave, the calculated position is negative (invalid), this has been fixed as well)

@joekaufmanexpensify
Copy link
Contributor

joekaufmanexpensify commented Nov 28, 2022

Triaging this now:

From this SO: https://stackoverflow.com/c/expensify/questions/14418

  • The "bug" is actually a bug:
  • The bug is not a duplicate report of an existing GH (close the GH and add any novel details to the original GH instead):
  • The bug is reproducible, following the reproduction steps:
  • If you're unable to reproduce the bug, add the Needs reproduction label. Comment on the issue outlining the steps you took to try to reproduce the bug, your results and tag the issue reporter and the Applause QA member who created the issue. Ask them to clarify reproduction steps and/or to check the reproduction steps again. Close issue.:
  • The GH template is filled out as fully as possible -- this means the GH body and title are clear (ie. could an external contributor understand it and work on it?):
  • The GH was created by an Expensify employee or a QA tester:
  • If the bug is an OldDot issue, you should decide whether it is widespread enough to justify fixing or it is better to wait for reunification. If it's better to wait, close the GH & provide this justification:
  • If there's a link to Slack, check the discussion to see if we decided not to fix it:
  • Decide if the GH should be resolved by an External contributor or Internal engineer, add the appropriate label:

@joekaufmanexpensify
Copy link
Contributor

joekaufmanexpensify commented Nov 28, 2022

I can reproduce this on web. Added some more detail to reproduction steps. This is a niche bug, however it can be reproduced, so I think we proceed with fixing it.

@joekaufmanexpensify
Copy link
Contributor

My thinking is this should be external. Assigning to engineering to confirm!

@melvin-bot
Copy link

melvin-bot bot commented Nov 28, 2022

Triggered auto assignment to @johnmlee101 (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

@johnmlee101
Copy link
Contributor

Yep, confirmed. At first I thought it was the skin-tone modifiers for emoji but it seems to be injecting it in a way that splits the unicode incorrectly.

@johnmlee101 johnmlee101 added the External Added to denote the issue can be worked on by a contributor label Nov 28, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 28, 2022

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

@melvin-bot melvin-bot bot changed the title Shows incorrect emoji while combining the manual and emoji picker selected emoji within the text [$1000] Shows incorrect emoji while combining the manual and emoji picker selected emoji within the text Nov 28, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 28, 2022

Job added to Upwork: https://www.upwork.com/jobs/~016d120322c0f448f0

@melvin-bot
Copy link

melvin-bot bot commented Nov 28, 2022

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 28, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 28, 2022

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

@Pujan92
Copy link
Contributor

Pujan92 commented Nov 29, 2022

As we are removing the character between the emoji string(: smile:) I think prevState selection logic won't work in the following code.

Initial proposal screencast

ff99a282-339f-4945-b1b8-6bbed6009d52.webm

@thesahindia
Copy link
Member

@johnmlee101 @joekaufmanexpensify, I won't be able to get to this today. Please re-assign.

@thesahindia thesahindia removed their assignment Nov 29, 2022
@johnmlee101 johnmlee101 added External Added to denote the issue can be worked on by a contributor and removed External Added to denote the issue can be worked on by a contributor labels Nov 29, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 29, 2022

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

@melvin-bot

This comment was marked as outdated.

@melvin-bot
Copy link

melvin-bot bot commented Nov 29, 2022

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

@melvin-bot melvin-bot bot removed the Overdue label May 9, 2023
@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Still on hold.

@joekaufmanexpensify
Copy link
Contributor

Same

@hannojg
Copy link
Contributor

hannojg commented May 31, 2023

Hey,

#12854 has been first put on hold for a now closed and dismissed PR. Afterwards it has been put on hold for another PR, but this PR is only addressing an android issue.

So I'd say this issue can be taken off hold, and we can again look into proposals!

@joekaufmanexpensify
Copy link
Contributor

Sounds good! @johnmlee101 and @sobitneupane does that sound good to y'all as well?

@sobitneupane
Copy link
Contributor

Testing if it is still reproducible: Yes. It is reproducible.

I don't think we can take off hold. We would want the issue to be fixed on android and IOS. We should still wait for #12854 to fix issue on android.

@hannojg Is there any issue open that you know that fixes the selection issue on IOS?

@hannojg
Copy link
Contributor

hannojg commented Jun 9, 2023

The issue right now is on hold for another issue that fixes a bug on android, while this issue is a web issue. They are in that sense not related.
The android fix will change nothing about this issue, so it doesn't make sense to me to have it on hold for #12854.

For iOS there is this issue:

I confirmed that the issue will be fixed once we upgrade the app to fabric renderer.

@joekaufmanexpensify
Copy link
Contributor

@johnmlee101 curious what you think here?

@johnmlee101
Copy link
Contributor

As long as both issues don't overlap or conflict with each other, I think we can remove off HOLD.

@sobitneupane
Copy link
Contributor

This issue exists on all platform not only Web. And to confirm the solution works well, the selection issues on IOS and android should be handled first.

@joekaufmanexpensify
Copy link
Contributor

Got it. @sobitneupane that would mean in fact leaving this on hold until 12854 is done. Is that right?

@joekaufmanexpensify
Copy link
Contributor

Still waiting for confirmation

@sobitneupane
Copy link
Contributor

@joekaufmanexpensify yes.

@joekaufmanexpensify
Copy link
Contributor

Got it, ty!

@joekaufmanexpensify
Copy link
Contributor

Still on hold

@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Still on hold

@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Same.

@joekaufmanexpensify
Copy link
Contributor

Held

@joekaufmanexpensify joekaufmanexpensify added Monthly KSv2 and removed Weekly KSv2 labels Aug 21, 2023
@joekaufmanexpensify
Copy link
Contributor

Same

1 similar comment
@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Same.

@joekaufmanexpensify
Copy link
Contributor

Same

@joekaufmanexpensify
Copy link
Contributor

Held

@joekaufmanexpensify
Copy link
Contributor

Just retested this and its no longer reproducible. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering External Added to denote the issue can be worked on by a contributor Monthly KSv2
Projects
None yet
Development

No branches or pull requests