App icon indicating copy to clipboard operation
App copied to clipboard

[$500] Taxes - User can access the background list using the arrow keys while the RHP is open

Open lanitochka17 opened this issue 1 year ago β€’ 16 comments

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


Version Number: 1.4.57-2 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to Paid workspace > Taxes
  2. Open one tax setting
  3. Press on the down and up arrow keys on the keyboard
  4. Go back and go to categories settings
  5. Open one category setting
  6. Press on the down and up arrow keys on the keyboard

Expected Result:

Pressing on the arrow keys on the keyboard should do nothing as there is an RHP open

Actual Result:

Even if RHP is open pressing on the arrow keys moves through the background list

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • [ ] Android: Native
  • [ ] Android: mWeb Chrome
  • [ ] iOS: Native
  • [ ] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [ ] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/a6ac1e8d-cdca-4362-a052-9c07a0de9ee4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01008d99761a20e1bb
  • Upwork Job ID: 1773361277524193280
  • Last Price Increase: 2024-03-28
  • Automatic offers:
    • jayeshmangwani | Reviewer | 0
    • ZhenjaHorbach | Contributor | 0

lanitochka17 avatar Mar 27 '24 19:03 lanitochka17

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

melvin-bot[bot] avatar Mar 27 '24 19:03 melvin-bot[bot]

@CortneyOfstad FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 avatar Mar 27 '24 19:03 lanitochka17

Proposal

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

Taxes - User can access the background list using the arrow keys while the RHP is open

What is the root cause of that problem?

The main problem with the issue is that we do not process this case in any way when we're out of focus inside ArrowKeyFocusManager which we use for BaseOptionsSelector and BaseSelectionList

https://github.com/Expensify/App/blob/e87d35d8af177df33c4fdfbf221ead732efec310/src/components/ArrowKeyFocusManager.js#L79-L83

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

Since we only use this ArrowKeyFocusManager for lists, the best way to fix this is to make changes inside the manager to cover changes for both BaseOptionsSelector and BaseSelectionList

To fix this issue we can update ArrowKeyFocusManager and update condition onArrowUpKey and onArrowDownKey when we're out of focus

For this, we need to create a wrapper to get isFocused value for ArrowKeyFocusManager

function ArrowKeyFocusManager(props) {
    const isFocused = useIsFocused();

    return (
        <ArrowKeyFocusManagerBody
            isFocused={isFocused}
            {...props}
        />
    );
}

export default ArrowKeyFocusManager;

And then update conditions to disable onArrowUpKey and onArrowDownKey when we're out of focus

https://github.com/Expensify/App/blob/e87d35d8af177df33c4fdfbf221ead732efec310/src/components/ArrowKeyFocusManager.js#L80

https://github.com/Expensify/App/blob/e87d35d8af177df33c4fdfbf221ead732efec310/src/components/ArrowKeyFocusManager.js#L99

if (this.props.maxIndex < 0 || !this.props.isFocused) {

Plus we might want to reset the index offset state when we leave the screen For this inside BaseOptionsSelector and BaseSelectionList we can set indexOffset as -1 when we leave the current screen using useEffect or componentDidUpdate (As alternative inside ArrowKeyFocusManager)

And if we want, we can always add an additional parameter that will make it possible to interact with lists when we are not in focus (But it doesn't make sense to me)

What alternative solutions did you explore? (Optional)

As an alternative, we can update onFocusedIndexChanged outside the manager And just disable the index change function when we're out of focus

https://github.com/Expensify/App/blob/669099756dc09345a4415495f168604f7df9d2bb/src/components/SelectionList/BaseSelectionList.tsx#L467

https://github.com/Expensify/App/blob/3a61938f54e46211152a2b42832ae3946cad847b/src/components/OptionsSelector/BaseOptionsSelector.js#L617

ZhenjaHorbach avatar Mar 27 '24 20:03 ZhenjaHorbach

Proposal

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

Taxes - User can access the background list using the arrow keys while the RHP is open

What is the root cause of that problem?

We do not disable Arrow keys for SelectionList here

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

  1. Add const isFocused = useIsFocused(); here and add disableKeyboardShortcuts={!isFocused} prop to SelectionList

  2. Update this line like below

maxIndex={disableKeyboardShortcuts ? -1 : slicedSections.flatMap((section) => section.data).length - 1}

We can add new disableArrowKeys prop to disable the arrow keys instead of using the disableKeyboardShortcuts so as not to use one prop to disable different actions

What alternative solutions did you explore? (Optional)

shahinyan11 avatar Mar 27 '24 20:03 shahinyan11

Job added to Upwork: https://www.upwork.com/jobs/~01008d99761a20e1bb

melvin-bot[bot] avatar Mar 28 '24 14:03 melvin-bot[bot]

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

melvin-bot[bot] avatar Mar 28 '24 14:03 melvin-bot[bot]

@jayeshmangwani we have some proposals for review above β€” thanks!

CortneyOfstad avatar Mar 28 '24 14:03 CortneyOfstad

Checking if this is VIP-VSP here

CortneyOfstad avatar Mar 28 '24 14:03 CortneyOfstad

Actually, it's wave-collect so assigning that now πŸ‘

CortneyOfstad avatar Mar 28 '24 18:03 CortneyOfstad

Thanks for the proposal @shahinyan11 , your changes will work on the Workspace Taxes page but similar issue is on the Workspaces's Distance rates, Categories , Tags pages too, so rather we would fix it in the SelectionList would be the good idea.

@ZhenjaHorbach's Proposal looks good to me, tested locally by applying changes and changes looks good, and @ZhenjaHorbach IMO resetting the index is not needed here when we leave the screen, key down and key up will not work when SectionList's screen is not focused, but keyboard shortcuts will work, adding a video below to checking the effect after applying changes in the proposal

Video:

https://github.com/Expensify/App/assets/35371050/e9689fd9-c0d2-45ab-b732-ab7ddbd807de

πŸŽ€ πŸ‘€ πŸŽ€ C+ reviewed

jayeshmangwani avatar Mar 29 '24 10:03 jayeshmangwani

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

melvin-bot[bot] avatar Mar 29 '24 10:03 melvin-bot[bot]

Proposal

Updated. Simplified changes and and fixed the issue in BaseSelectionList level to cover it for all screens Take a look please @jayeshmangwani @pecanoro

shahinyan11 avatar Mar 29 '24 11:03 shahinyan11

Assigning @ZhenjaHorbach to the issue!

pecanoro avatar Mar 29 '24 16:03 pecanoro

πŸ“£ @jayeshmangwani πŸŽ‰ 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[bot] avatar Mar 29 '24 16:03 melvin-bot[bot]

πŸ“£ @ZhenjaHorbach πŸŽ‰ 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[bot] avatar Mar 29 '24 16:03 melvin-bot[bot]

πŸ“£ @ZhenjaHorbach πŸŽ‰ 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 πŸ“–

PR will be ready on the weekend

ZhenjaHorbach avatar Mar 29 '24 16:03 ZhenjaHorbach

PR hit staging earlier today!

trjExpensify avatar Apr 08 '24 21:04 trjExpensify

For some reason this did not move to daily or apply payment details, but payment is due to day!

CortneyOfstad avatar Apr 17 '24 14:04 CortneyOfstad

Payment Summary

@jayeshmangwani β€” paid $500 via Upwork @ZhenjaHorbach β€” paid $500 via Upwork

CortneyOfstad avatar Apr 17 '24 14:04 CortneyOfstad

@jayeshmangwani can you confirm if this needs a regression test and make the proposal before EOD? Thank you!

CortneyOfstad avatar Apr 17 '24 14:04 CortneyOfstad

This is not a regression from any PR, but it was missed when we created ArrowKeyFocusManager, and later, the issue was visible after we created RHP. I am proposing regression test steps below. Please let me know if you have any other suggestions

Regression Test Steps

  1. Go to Collect Workspace> Taxes
  2. Open one tax setting
  3. Press the down and up arrow keys on the keyboard
  4. Verify that pressing the arrow keys on the keyboard does nothing, as there is an RHP open
  5. Go back and go to categories settings
  6. Open one category setting
  7. Press the down and up arrow keys on the keyboard
  8. Verify that pressing the arrow keys on the keyboard does nothing, as there is an RHP open

Do you agree πŸ‘ or πŸ‘Ž ?

jayeshmangwani avatar Apr 17 '24 22:04 jayeshmangwani

This is not a regression from any PR, but it was missed when we created ArrowKeyFocusManager, and later, the issue was visible after we created RHP. I am proposing regression test steps below. Please let me know if you have any other suggestions

Regression Test Steps

  1. Go to Collect Workspace> Taxes
  2. Open one tax setting
  3. Press the down and up arrow keys on the keyboard
  4. Verify that pressing the arrow keys on the keyboard does nothing, as there is an RHP open
  5. Go back and go to categories settings
  6. Open one category setting
  7. Press the down and up arrow keys on the keyboard
  8. Verify that pressing the arrow keys on the keyboard does nothing, as there is an RHP open

Do you agree πŸ‘ or πŸ‘Ž ?

@CortneyOfstad

jayeshmangwani avatar Apr 23 '24 10:04 jayeshmangwani

Sorry about that @jayeshmangwani! I agree to the regression test and getting that created now!

CortneyOfstad avatar Apr 24 '24 14:04 CortneyOfstad

Regression is here β€” closing!

CortneyOfstad avatar Apr 24 '24 14:04 CortneyOfstad