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-09-29] [$500] Chat - Emoji suggestion does not auto close after inserting eye emoji #27156

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

@izarutskaya
Copy link

izarutskaya 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 in ':eye' and colon in end to insert 👁️ emoji
  4. Observe that suggestion does not close
  5. Try the same for ':heart', ':joy' (colon in end of both examples) and observe that suggestion is closed automatically

Expected Result:

App should close the suggestion automatically once emoji is inserted as it does for emojis like 😂 (joy), ❤️ (heart)

Actual Result:

App does not close the suggestion automatically for 👁️ (eye) emoji

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: v1.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

suggestion.not.autoclosed.eye.emoji.mp4
Recording.1495.mp4

Expensify/Expensify Issue URL:

Issue reported by: @dhanashree-sawant

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693927993330749

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e13c88c48491a5e5
  • Upwork Job ID: 1701246242089250816
  • Last Price Increase: 2023-09-11
  • Automatic offers:
    • jjcoffee | Reviewer | 26727033
    • ahmedGaber93 | Contributor | 26727035
    • dhanashree-sawant | Reporter | 26727037
@izarutskaya izarutskaya 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 Chat - Emoji suggestion does not auto close after inserting eye emoji [$500] Chat - Emoji suggestion does not auto close after inserting eye emoji Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01e13c88c48491a5e5

@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 @abekkala (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 - @jjcoffee (External)

@ahmedGaber93
Copy link
Contributor

Proposal

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

Emoji suggestion does not autoclose after inserting eye emoji

What is the root cause of that problem?

This because we only call calculateEmojiSuggestion after onSelectionChange and in this emoji case the selection not changed.

const onSelectionChange = useCallback(
(e) => {
/**
* we pass here e.nativeEvent.selection.end directly to calculateEmojiSuggestion
* because in other case calculateEmojiSuggestion will have an old calculation value
* of suggestion instead of current one
*/
calculateEmojiSuggestion(e.nativeEvent.selection.end);
},
[calculateEmojiSuggestion],
);

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

We can do with several ways:
solution 1: if the comment replaces emoji and selection not change resetSuggestions

const updateComment = useCallback(() => {
  ...
  if (commentValue !== newComment) {
      const remainder = ComposerUtils.getCommonSuffixLength(commentRef.current, newComment);
      
      // if the comment replaces emoji and selection not change `resetSuggestions`
      if (selection.end === newComment.length - remainder){
          suggestionsRef.current.resetSuggestions();
      }
      ...
  }
// add selection to deps
}, [selection, ...]);         

solution 2: use setSelection directly in Composer props onSelectionChange={setSelection} and replace onSelectionChange function here with this useEffect

useEffect(() => {
    if (!suggestionsRef.current) {
        return;
    }
    suggestionsRef.current.onSelectionChange({nativeEvent : {selection}});
}, [suggestionsRef, selection, value]);

solution 3: use setSelection directly in Composer props like solution 2 and create onCommetValueChange in Sugguestions.js which has calculateEmojiSuggestion and calculateMentionSuggestion inside it, and use it useEffect when comment change

useEffect(() => {
    if (!suggestionsRef.current) {
        return;
    }
    suggestionsRef.current.onCommetValueChange(selection.end);
}, [suggestionsRef, selection, value]);

What alternative solutions did you explore? (Optional)

we can also move the logic to Suggestions.js or SuggestionEmoji and SuggestionMention with the same idea.

@jjcoffee
Copy link
Contributor

@ahmedGaber93 Thanks for the proposal! Could you clarify a bit more as to why the selection doesn't change specifically for the eye emoji?

@bernhardoj
Copy link
Contributor

Proposal

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

Typing 👁️ emoji code don't close the emoji suggestion.

What is the root cause of that problem?

When we type a complete emoji code, it should also close the emoji suggestion. This is currently handled by calculateEmojiSuggestion.

const nextState = {
suggestedEmojis: [],
colonIndex,
shouldShowEmojiSuggestionMenu: false,
};
const newSuggestedEmojis = EmojiUtils.suggestEmojis(leftString, preferredLocale);
if (newSuggestedEmojis.length && isCurrentlyShowingEmojiSuggestion) {
nextState.suggestedEmojis = newSuggestedEmojis;
nextState.shouldShowEmojiSuggestionMenu = !_.isEmpty(newSuggestedEmojis);
}
setSuggestionValues((prevState) => ({...prevState, ...nextState}));

calculateEmojiSuggestion is called in onSelectionChange callback of composer text input.

const onSelectionChange = useCallback(
(e) => {
/**
* we pass here e.nativeEvent.selection.end directly to calculateEmojiSuggestion
* because in other case calculateEmojiSuggestion will have an old calculation value
* of suggestion instead of current one
*/
calculateEmojiSuggestion(e.nativeEvent.selection.end);
},
[calculateEmojiSuggestion],
);

However, onSelectionChange is not triggered if we type :eye: emoji code. After doing some investigation, here is what I found:

  1. onChangeText is triggered before onSelectionChange
  2. onSelectionChange won't be triggered if the value is the same

In the case of :eye: emoji code, when we type 👁️ into the composer, here is what happens:

  1. User type :eye
  2. The current selection value is {start: 4, end: 4}
  3. User type :, the text now is :eye:. This triggers onChangeText which will call updateComment to replace the emoji code with the emoji and add a space, :eye: -> 👁️
  4. The eye emoji length is 3 + the space length 1, so the selection is still {start: 4, end: 4}
  5. No onSelectionChange is triggered

If we remove the whitespace added to emoji from here, the issue is gone.

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

Hide the emoji suggestion when an emoji is replaced here

if (!_.isEmpty(emojis)) {
insertedEmojisRef.current = [...insertedEmojisRef.current, ...emojis];
debouncedUpdateFrequentlyUsedEmojis();
}

suggestionsRef.current.resetSuggestions();

@ahmedGaber93
Copy link
Contributor

ahmedGaber93 commented Sep 12, 2023

Could you clarify a bit more as to why the selection doesn't change specifically for the eye emoji?

@jjcoffee After some search I found not all emoji length is 2, but it up to 7.
This why only eye has this issue, so the selection will not change in specific emojis if typed length is equal replaced length without selection change

A single rendered emoji can have a JavaScript string length of up to 7 if it contains additional Unicode scalar values that represent a skin tone modifier, gender specification, and multicolor rendering (see source).

Screenshot 2023-09-12 at 8 02 06 PM

also removing the whitespace added to emoji may fix this issue, but not fix the root cause because we still may have emojis with a typed length equal replaced length for now or future.

@melvin-bot melvin-bot bot added the Overdue label Sep 15, 2023
@jjcoffee
Copy link
Contributor

Happy to go with @ahmedGaber93's proposal here. The RCA is correct, though it could use a bit more detail (as in @bernhardoj's proposal), and the first solution seems good. I would just add that I don't think it's necessary to check whether the selection has changed; we can just always reset the suggestions if we're replacing an emoji.

@bernhardoj's proposal has a much more detailed RCA, which I appreciate a lot, but the solution is basically the same as in @ahmedGaber93's proposal.

🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

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

@bernhardoj
Copy link
Contributor

I thought the proposal should have a correct RCA, so I posted mine 😅.

Btw, hiding the suggestion inside this if will always hide the suggestion every time we type if the text contains an emoji.

if (!_.isEmpty(emojis)) {
insertedEmojisRef.current = [...insertedEmojisRef.current, ...emojis];
debouncedUpdateFrequentlyUsedEmojis();
}

emojis contains all existing and new emojis.

@ahmedGaber93
Copy link
Contributor

The RCA is correct, though it could use a bit more detail (as in bernhardoj's #27156 (comment)).

Thanks @jjcoffee, I will take care about including more details from the first time rather than explain it if needed.

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Sep 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

📣 @ahmedGaber93 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot
Copy link

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

@MariaHCD
Copy link
Contributor

Not overdue, just assigned

@jjcoffee
Copy link
Contributor

@ahmedGaber93 don't forget to let us know when we can expect a PR, thanks!

@ahmedGaber93
Copy link
Contributor

@jjcoffee PR is now ready for review.

@melvin-bot
Copy link

melvin-bot bot commented Sep 20, 2023

🎯 ⚡️ Woah @jjcoffee / @ahmedGaber93, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @ahmedGaber93 got assigned: 2023-09-18 07:09:55 Z
  • when the PR got merged: 2023-09-20 08:05:11 UTC

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 Sep 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - Emoji suggestion does not auto close after inserting eye emoji [HOLD for payment 2023-09-29] [$500] Chat - Emoji suggestion does not auto close after inserting eye emoji Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.72-11 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-09-29. 🎊

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 Sep 22, 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:

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

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Sep 29, 2023
@sophiepintoraetz
Copy link
Contributor

@dhanashree-sawant @ahmedGaber93 have been paid - @jjcoffee - I'll pay once the BZ checklist is completed!

@melvin-bot melvin-bot bot removed the Overdue label Oct 2, 2023
@sophiepintoraetz
Copy link
Contributor

Bump for you @jjcoffee!

@jjcoffee
Copy link
Contributor

jjcoffee commented Oct 3, 2023

  • The PR that introduced the bug has been identified. Link to the PR: N/A - behaviour has always existed.
  • 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: N/A
  • 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: N/A - pretty hard case to catch as it only happens for specific lengths of emojis
  • Determine if we should create a regression test for this bug. Yes
  • 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. See below

@jjcoffee
Copy link
Contributor

jjcoffee commented Oct 3, 2023

Regression Test Proposal

  1. Open the app
  2. Open any report
  3. Type in ':eye' to open emoji suggestion list
  4. Add a colon at the end to insert the emoji
  5. Verify that the suggestion list closes

Do we agree 👍 or 👎

@jjcoffee
Copy link
Contributor

jjcoffee commented Oct 3, 2023

@sophiepintoraetz Checklist complete, apologies for the delay!

@sophiepintoraetz
Copy link
Contributor

All paid!

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

7 participants