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 #16078][$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key #16426

Closed
2 of 6 tasks
kavimuru opened this issue Mar 22, 2023 · 35 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2

Comments

@kavimuru
Copy link

kavimuru commented Mar 22, 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. Type in :smiley
  2. two suggestions will pop up, the first one will be highlighted
  3. press down arrow key, the second suggestion will be correctly highlighted
  4. press down arrow key

Expected Result:

Should highlight 1st one and hit enter will show the emoji in the compose box

Actual Result:

Now the highlight will be invisible, and pressing enter will not do anything throws an error into the console
pressing the down arrow key three more times will bring the highlight back to the first item (basically its behaving like if there were 5 suggestions in total

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.2.88-0
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:

Recording.140.mp4

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011af615711c2a4640
  • Upwork Job ID: 1638683762211266560
  • Last Price Increase: 2023-03-22
@kavimuru kavimuru added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 22, 2023
@MelvinBot
Copy link

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

@MelvinBot
Copy link

MelvinBot commented Mar 22, 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

@kadiealexander
Copy link
Contributor

I could reproduce, however I didn't get any console errors and I could make the cursor go to the first option using 5 down button presses.

2023-03-23_12-25-00.mp4

@kadiealexander kadiealexander added the External Added to denote the issue can be worked on by a contributor label Mar 22, 2023
@melvin-bot melvin-bot bot changed the title Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key [$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key Mar 22, 2023
@MelvinBot
Copy link

Job added to Upwork: https://www.upwork.com/jobs/~011af615711c2a4640

@MelvinBot
Copy link

Current assignee @kadiealexander 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 - @mollfpr (External)

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

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

@allroundexperts
Copy link
Contributor

allroundexperts commented Mar 22, 2023

Proposal

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

The down arrow key does not correctly focus the suggested emojis.

What is the root cause of that problem?

The root cause of the issue is this line. We're getting an incorrect emojiRowCount value because of using Math.max function for the actual number of suggestions and the default number to show (5 for large screen). In this particular case, the actual number of emoji count is 2. However, Math.max results in the count to be 5.

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

We can just replace this expression to use Math.min instead.

A more detailed and readable way of doing the same thing would be to replace this with:

let emojiRowCount = 0;

    if (isEmojiPickerLarge) {
        emojiRowCount = numRows <= CONST.EMOJI_SUGGESTER.MAX_AMOUNT_OF_ITEMS ? numRows : CONST.EMOJI_SUGGESTER.MAX_AMOUNT_OF_ITEMS;
    } else {
        emojiRowCount = numRows <= CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS ? numRows : CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS;
    }

What alternative solutions did you explore? (Optional)

None

@Prince-Mendiratta
Copy link
Contributor

Prince-Mendiratta commented Mar 23, 2023

Proposal

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

When there are less than 3 items suggested, there seem to be ghost values for the emoji suggestions that are not highlighted and throw console error when Enter key is clicked.

What is the root cause of that problem?

In the getMaxArrowIndex, we set the value to necessarily be a maximum of 5 for large screens. Typing :smiley results in only 2 suggestions being there, but since the maximum has to be 5, it changes to 5, resulting in empty values.

const emojiRowCount = isEmojiPickerLarge
? Math.max(numRows, CONST.EMOJI_SUGGESTER.MAX_AMOUNT_OF_ITEMS)
: Math.max(numRows, CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS);

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

By default the maximum amount of emojis that can be suggested is 5, as can be seen here:

function suggestEmojis(text, limit = 5) {

This is called here:

const newSuggestedEmojis = EmojiUtils.suggestEmojis(leftString);

So that is implied and we only need to modify the condition to show a maximum of 3 emojis for smaller screens. A cleaner way to do this would be via this:

    let emojiRowCount = numRows;
    if (numRows > CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS) {
        emojiRowCount = !isEmojiPickerLarge && CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS;
    }

@fedirjh
Copy link
Contributor

fedirjh commented Mar 23, 2023

Proposal

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

The Up/Down arrow keys does not correctly focus the suggested emojis when suggestion list have fewer that 5 emojis

What is the root cause of that problem?

ArrowKeyFocusManager's maxIndex prop doesn’t reflect the actual size of emoji suggestion list.

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

We should pass actual size of emoji suggestion to ArrowKeyFocusManager here

maxIndex={getMaxArrowIndex(this.state.suggestedEmojis.length, this.state.isEmojiPickerLarge)}

         maxIndex={this.state.suggestedEmojis.length - 1}

@kaushiktd
Copy link
Contributor

Please re-state the problem that we are trying to solve in this issue.
Pressing down the arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and the console error clicking Enter key

What is the root cause of that problem?
There is an issue with getMaxArrowIndex function in below mentioned file:

const emojiRowCount = isEmojiPickerLarge
? Math.max(numRows, CONST.EMOJI_SUGGESTER.MAX_AMOUNT_OF_ITEMS)
: Math.max(numRows, CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS);

In this function Math.max() function is used and this method returns the number with the highest value.
In this function you are using CONST.EMOJI_SUGGESTER.MAX_AMOUNT_OF_ITEMS that has a static value of 5, so if suggested emojis are 2 or 3 it will always return 5.

What changes do you think we should make in order to solve the problem?
You need to return the exact number of suggested values so please change getMaxArrowIndex function with the below line:

const emojiRowCount = numRows - 1; (-1 because array index starts from 0 always);

@Pujan92
Copy link
Contributor

Pujan92 commented Mar 23, 2023

Proposal

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

Up/Down arrow key goes to 5 rows every time even though available suggestions are fewer which causes console error.

What is the root cause of that problem?

We are not setting the correct maxIndex here for ArrowKeyFocusManager.

maxIndex={getMaxArrowIndex(this.state.suggestedEmojis.length, this.state.isEmojiPickerLarge)}

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

We can get rid of the getMaxArrowIndex method as it seems not required and use array slicing for smaller screens at the time we received newSuggestedEmojis. To achieve it we can do below changes

  1. Slice the results to MIN_AMOUNT_OF_ITEMS for smaller screens here otherwise do not
    nextState.suggestedEmojis = newSuggestedEmojis;
nextState.suggestedEmojis = this.state.isEmojiPickerLarge
         ? newSuggestedEmojis
          : newSuggestedEmojis.slice(0, CONST.EMOJI_SUGGESTER.MIN_AMOUNT_OF_ITEMS);
  1. Use suggestedEmojis.length for the maxIndex here

    maxIndex={getMaxArrowIndex(this.state.suggestedEmojis.length, this.state.isEmojiPickerLarge)}

    maxIndex={this.state.suggestedEmojis.length - 1}

  2. Remove getMaxArrowIndex method

Conclusion

  • For isEmojiPickerLarge it will assign newSuggestedEmojis as it is(which won't be more than 5 for sure)
  • For not isEmojiPickerLarge it will slice the newSuggestedEmojis with max to MIN_AMOUNT_OF_ITEMS

@mollfpr
Copy link
Contributor

mollfpr commented Mar 23, 2023

Thank you guys for the proposal! Everyone has all the correct RCA, and I like proposal from @allroundexperts because it has the correct logic and straightforward solution. (Only change the Math.max to Math.min, we can keep the ternary)

🎀 👀 🎀 C+ reviewed!

cc @nkuoch

@Pujan92
Copy link
Contributor

Pujan92 commented Mar 23, 2023

@mollfpr isn't this makes more sense to take out the extra code and simplify it?
Just tagging @perunt as the function(getMaxArrowIndex) added in their PR to know whether it is required or not(as per my proposal)

@mollfpr
Copy link
Contributor

mollfpr commented Mar 24, 2023

@Pujan92 You have a point. Currently, the behavior on the smaller device is showing 5 emojis. With your proposal, we are only showing 3 emojis. We can wait for @perunt to clarify this.

Screen.Recording.2023-03-24.at.19.26.24.mov

@allroundexperts I do not recommend creating a PR before you are assigned to the issue. Let's wait @nkuoch first.

@allroundexperts
Copy link
Contributor

@Pujan92 You have a point. Currently, the behavior on the smaller device is showing 5 emojis. With your proposal, we are only showing 3 emojis. We can wait for @perunt to clarify this.

@allroundexperts I do not recommend creating a PR before you are assigned to the issue. Let's wait @nkuoch first.

@mollfpr I created the PR on my fork. I'm not sure why it shows up here.

@mollfpr
Copy link
Contributor

mollfpr commented Mar 24, 2023

@allroundexperts Ohyea, sorry I didn't realize that. Probably because you mention the issue.

@perunt
Copy link
Contributor

perunt commented Mar 24, 2023

Hey guys! I'm working on implementing inline suggestions so that behavior will be changed, so it probably not make sense to make any changes here

@mollfpr
Copy link
Contributor

mollfpr commented Mar 25, 2023

Thanks @perunt, for clarifying this!

@nkuoch @kadiealexander Let's hold this and come back after @perunt implementation is done.

@melvin-bot melvin-bot bot added the Overdue label Mar 27, 2023
@kadiealexander kadiealexander changed the title [$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key [HOLD for #16708][$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key Mar 28, 2023
@MelvinBot
Copy link

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 17, 2023
@MelvinBot
Copy link

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

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

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

1 similar comment
@MelvinBot
Copy link

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

@kadiealexander
Copy link
Contributor

@grgia and @mollfpr could you please assess the PR here #16708 and see if we're able to proceed here?

@grgia
Copy link
Contributor

grgia commented Apr 17, 2023

@kadiealexander the issue we're holding on is #16078 (still open) I think the title was a typo. I'll update it.

@grgia grgia changed the title [HOLD for #16708][$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key [HOLD for #16078][$1000] Pressing down arrow key for the 3rd time does not highlight the 1st one of the 2 emoji suggestions and console error clicking Enter key Apr 17, 2023
@kadiealexander
Copy link
Contributor

🤦 Thanks @grgia!!

@kadiealexander kadiealexander added Weekly KSv2 and removed Daily KSv2 labels Apr 19, 2023
@melvin-bot melvin-bot bot added the Overdue label Apr 27, 2023
@kadiealexander
Copy link
Contributor

Still on hold.

@melvin-bot melvin-bot bot removed the Overdue label Apr 28, 2023
@melvin-bot melvin-bot bot added the Overdue label May 8, 2023
@kadiealexander
Copy link
Contributor

Same as above.

@melvin-bot melvin-bot bot removed the Overdue label May 9, 2023
@szebniok szebniok mentioned this issue May 10, 2023
57 tasks
@melvin-bot melvin-bot bot added the Overdue label May 17, 2023
@kadiealexander
Copy link
Contributor

Still on hold.

@melvin-bot melvin-bot bot removed the Overdue label May 18, 2023
@melvin-bot melvin-bot bot added the Overdue label May 26, 2023
@kadiealexander
Copy link
Contributor

The issue this was on hold for has made it to production! @puneetlath or @kavimuru would you mind re-testing this and ensuring it's not still a bug? I am no longer able to reproduce it.

@melvin-bot melvin-bot bot removed the Overdue label May 30, 2023
@puneetlath
Copy link
Contributor

I'm also no longer able to reproduce.

@kadiealexander
Copy link
Contributor

Woohoo! Closing this one :)

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. External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Weekly KSv2
Projects
None yet
Development

No branches or pull requests