You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2024-03-25] [$500] Message action menu - Last option is not selected when pressing up key #36245
changed the title [-]Message action menu - Last option is not selected when pressing up key[/-][+][$500] Message action menu - Last option is not selected when pressing up key[/+]on Feb 9, 2024
What changes do you think we should make in order to solve the problem?
Instead of checking for the values < 0 (This case is only where the value can be -1 as when we go to the top of the list the last index value is always 0 and nothing below it!)
Update the while loop to check if the newFocusedIndex is at the top of the list, and if so then return the maxIndex, if we enable the property to not traverse cyclic in the list then we stay at the top index itself
Please re-state the problem that we are trying to solve in this issue.
Message action menu - Last option is not selected when pressing up key
What is the root cause of that problem?
In the code below the while loop will be executed when the newFocusedIndex is 0 because disabledIndexes.includes(newFocusedIndex) will become true as we have the emojis container at the index 0 and we don't allow focus on it, and due to that the focusedIndex is set to -1 for once.
We also have similar bug in arrowDownCallback, there also we don't handle the case when the newFocusedIndex becomes greater than the maxIndex. This can be reproduced easily by passing last index number to disabledIndexes array inside BaseReportActionContextMenu or in any component we use useArrowKeyFocusManager. there also if we have the last index as disabled, the newFocusedIndex will be greater than the maxIndex which will cause focus lost.
arrow_down_issue.mp4
What changes do you think we should make in order to solve the problem?
For Up arrow key:
Instead of exiting the loop, we need to find the next focusable option from last, we can't directly return maxIndex because the maxIndex can also be disabled. For that we need to use the another while loop. Also, instead of using 0 as the minIndex we need to introduce a new parameter minIndex in useArrowKeyFocusManager and the default value will be zero. We need that for special cases like the emoji picker because there we need to get negative index because we want to focus on the input. We will pass headerIndices.length * -1 + 1 as the minIndex from EmojiPickerMenuWithRef.
changed the title [-][$500] Message action menu - Last option is not selected when pressing up key[/-][+][HOLD for payment 2024-03-25] [$500] Message action menu - Last option is not selected when pressing up key[/+]on Mar 18, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.53-2 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
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:
[@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
[@Ollyws] 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:
[@Ollyws] 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:
[@Ollyws] Determine if we should create a regression test for this bug.
[@Ollyws] 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.
[@puneetlath] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
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:
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
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.
Regression Test Proposal
1. Open any chat
2. Right click on any report action
3. Press on up key till you rich the top selectable option
4. Press up key once more
5. Verify that the last menu item is now highlighted
Activity
[-]Message action menu - Last option is not selected when pressing up key[/-][+][$500] Message action menu - Last option is not selected when pressing up key[/+]melvin-bot commentedon Feb 9, 2024
Job added to Upwork: https://www.upwork.com/jobs/~017003c89d832c6ad8
melvin-bot commentedon Feb 9, 2024
Triggered auto assignment to @puneetlath (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.kbecciv commentedon Feb 9, 2024
We think that this bug might be related to #vip-vsb
CC @quinthar
melvin-bot commentedon Feb 9, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws (
External)FitseTLT commentedon Feb 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Last option is not selected when pressing up key
What is the root cause of that problem?
Because index '0' is disabled it breaks early here
App/src/hooks/useArrowKeyFocusManager.ts
Lines 75 to 76 in b9aada8
What changes do you think we should make in order to solve the problem?
Change this
App/src/hooks/useArrowKeyFocusManager.ts
Lines 86 to 88 in 91ea979
to
And there is a similar problem with arrow key down too as there is no check if it is greater than
maxIndexso we can add the below hereWhat alternative solutions did you explore? (Optional)
allgandalf commentedon Feb 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
We reduce the value of
newFocusedIndexeverytime in the loop and when it hits beyond 0, we break the loop, thereby we lose the highlight from the listApp/src/hooks/useArrowKeyFocusManager.ts
Lines 74 to 76 in b9aada8
What changes do you think we should make in order to solve the problem?
Instead of checking for the
values < 0(This case is only where the value can be-1as when we go to the top of the list the last index value is always0and nothing below it!)Update the while loop to check if the
newFocusedIndexis at the top of the list, and if so then return themaxIndex, if we enable the property to not traverse cyclic in the list then we stay at the top index itselfWhat alternative solutions did you explore? (Optional)
N/A
Krishna2323 commentedon Feb 12, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Message action menu - Last option is not selected when pressing up key
What is the root cause of that problem?
In the code below the while loop will be executed when the
newFocusedIndexis0becausedisabledIndexes.includes(newFocusedIndex)will become true as we have the emojis container at the index0and we don't allow focus on it, and due to that thefocusedIndexis set to-1for once.App/src/hooks/useArrowKeyFocusManager.ts
Lines 73 to 77 in b9aada8
We also have similar bug in
arrowDownCallback, there also we don't handle the case when thenewFocusedIndexbecomes greater than themaxIndex. This can be reproduced easily by passing last index number todisabledIndexesarray insideBaseReportActionContextMenuor in any component we useuseArrowKeyFocusManager. there also if we have the last index as disabled, thenewFocusedIndexwill be greater than themaxIndexwhich will cause focus lost.arrow_down_issue.mp4
What changes do you think we should make in order to solve the problem?
For Up arrow key:
Instead of exiting the loop, we need to find the next focusable option from last, we can't directly return
maxIndexbecause themaxIndexcan also be disabled. For that we need to use the another while loop. Also, instead of using0as theminIndexwe need to introduce a new parameterminIndexinuseArrowKeyFocusManagerand the default value will be zero. We need that for special cases like the emoji picker because there we need to get negative index because we want to focus on the input. We will passheaderIndices.length * -1 + 1as theminIndexfromEmojiPickerMenuWithRef.We need to update the code below:
App/src/hooks/useArrowKeyFocusManager.ts
Lines 75 to 77 in b9aada8
To:
For Down arrow key:
We need to add the code below in the while loop of
arrowDownCallback:PS: Minor code changes or refactoring can be done during the PR, the general idea will be the same.
Result
fix_demo_arrow_keys.mp4
57 remaining items
puneetlath commentedon Mar 12, 2024
@FitseTLT @Ollyws How's this going?
Ollyws commentedon Mar 12, 2024
Just reviewing some details, should be good to go in a day or two.
[-][$500] Message action menu - Last option is not selected when pressing up key[/-][+][HOLD for payment 2024-03-25] [$500] Message action menu - Last option is not selected when pressing up key[/+]melvin-bot commentedon Mar 18, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Mar 18, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.53-2 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 2024-03-25. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Mar 18, 2024
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:
puneetlath commentedon Mar 22, 2024
@Ollyws friendly reminder about the checklist so that we can pay on Monday.
Ollyws commentedon Mar 23, 2024
BugZero Checklist:
#34581
#34581 (comment)
N/A
Yes.
Regression Test Proposal
Do we agree 👍 or 👎
puneetlath commentedon Mar 25, 2024
All paid. Thanks y'all!
Regression test issue is here: https://github.com/Expensify/Expensify/issues/382048