Skip to content

[Due for payment 2025-04-14] [$250] Workflows - Approver remains highlighted when navigating the list with keyboard #57606

Closed

Description

@IuliiaHerets

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.1.7-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+sj9032@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.3 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • Workspace has a few members.
  • Workflows are enabled.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Workflows.
  3. Click Submission frequency.
  4. Click Monthly > Date of month.
  5. Use down arrow to navigate the list.
  6. Note that the selected option is not highlighted and there is only one highlighted row.
  7. Close the RHP.
  8. Click on the existing workflow.
  9. Click Approver.
  10. Use down arrow to navigate the list.

Expected Result:

The selected user is not highlighted and there is only one highlighted row.

Actual Result:

The selected user remains highlighted and there are two highlighted rows.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6757358_1740734876228.20250228_172216.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021896618864180272606
  • Upwork Job ID: 1896618864180272606
  • Last Price Increase: 2025-03-10
  • Automatic offers:
    • dominictb | Contributor | 106528152
    • thelullabyy | Contributor | 106580173
Issue OwnerCurrent Issue Owner: @zanyrenney

Activity

  1. added
    Bug
    Daily
    on Feb 28, 2025
  2. melvin-bot commented on Feb 28, 2025

    @melvin-bot

    Triggered auto assignment to @zanyrenney (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. ryntgh commented on Feb 28, 2025

    @ryntgh
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-02-28 11:08:28 UTC.

    Proposal

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

    Workflows - Approver remains highlighted when navigating the list with keyboard

    What is the root cause of that problem?

    On WorkspaceWorkflowsApprovalsApproverPage we set shouldHighlightSelectedItem as true, which causes multiple rows to remain highlighted when navigating via the keyboard.

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

    We should adjust the SelectionList so that only one row is highlighted at any time.

    • Remove the shouldHighlightSelectedItem prop.
    • Add initiallyFocusedOptionKey={selectedApproverEmail} like we did here.
    • Add key={selectedApproverEmail} so that it re-mounts whenever the selected approver changes.
                        <SelectionList
                            key={selectedApproverEmail}
                            sections={sections}
                            ListItem={InviteMemberListItem}
                            textInputLabel={shouldShowListEmptyContent ? undefined : translate('selectionList.findMember')}
                            textInputValue={searchTerm}
                            onChangeText={setSearchTerm}
                            headerMessage={headerMessage}
                            onSelectRow={toggleApprover}
                            showScrollIndicator
                            shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
                            footerContent={button}
                            listEmptyContent={listEmptyContent}
                            shouldShowListEmptyContent={shouldShowListEmptyContent}
                            initiallyFocusedOptionKey={selectedApproverEmail}
                            shouldShowTextInput={shouldShowTextInput}
                        />

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    None

    What alternative solutions did you explore? (Optional)

    New-Expensify.mp4
  4. melvin-bot commented on Feb 28, 2025

    @melvin-bot

    📣 @ryntgh! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  5. melvin-bot commented on Feb 28, 2025

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  6. linhvovan29546 commented on Feb 28, 2025

    @linhvovan29546
    Contributor

    Proposal

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

    Workflows - Approver remains highlighted when navigating the list with keyboard

    What is the root cause of that problem?

    In the WorkspaceWorkflowsApprovalsApproverPage we have shouldHighlightSelectedItem props, so the selected item is always highlighted


    And we are missing initiallyFocusedOptionKey, causing the focus when pressing 'Tab' to always default to the first item(index 0).

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

                            sections={sections}
                            ListItem={InviteMemberListItem}
                            textInputLabel={shouldShowListEmptyContent ? undefined : translate('selectionList.findMember')}
                            textInputValue={searchTerm}
                            onChangeText={setSearchTerm}
                            headerMessage={headerMessage}
                            onSelectRow={toggleApprover}
                            showScrollIndicator
                            shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
                            footerContent={button}
                            listEmptyContent={listEmptyContent}
                            shouldShowListEmptyContent={shouldShowListEmptyContent}
                            // shouldHighlightSelectedItem //remove
                            shouldShowTextInput={shouldShowTextInput}
                            initiallyFocusedOptionKey={selectedApproverEmail} // allow update selected item via keyboard
                            shouldUpdateFocusedIndex // allow update selected item via keyboard
                        />

    Finally, remove the condition inside toggleApprover because it is called twice times by the 'Enter' key and once by the onPress event—leading to setSelectedApproverEmail being set to undefined when 'Enter' is pressed.

    const toggleApprover = (approver: SelectionListApprover) => {
    if (selectedApproverEmail === approver.login) {
    setSelectedApproverEmail(undefined);
    return;
    }
    setSelectedApproverEmail(approver.login);
    };

        const toggleApprover = (approver: SelectionListApprover) => {
            setSelectedApproverEmail(approver.login);
        };

    Optional: We can prevent toggleApprover from being called twice by adding shouldPreventEnterKeySubmit to InviteMemberListItem and only apply for this approver flow.

    Note: We can apply Optional above if we allow an unselected item, but I noticed that we do not allow setting the approver to undefined, so we can remove the condition inside toggleApprover, and it should be fine

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    N/A, Keyboard issue

    What alternative solutions did you explore? (Optional)

    N/A

  7. thelullabyy commented on Feb 28, 2025

    @thelullabyy
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-03-17 09:18:42 UTC.

    Proposal

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

    The selected user remains highlighted and there are two highlighted rows.

    What is the root cause of that problem?

    In the approver page, we set shouldHighlightSelectedItem to SelectionList. So the selected option will always be highlighted

    shouldHighlightSelectedItem was added in #50541. At that time, this prop was added to highlight the selected option.

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

    We need to remove shouldHighlightSelectedItem completely in all places in the codebase (This is an important step to prevent using this prop in the future)

    And then introduce a new way to solve this bug. Let's add these props

                            initiallyFocusedOptionKey={selectedApproverEmail} 
                            shouldUpdateFocusedIndex 
    

    For enter key problem, we can wrap toggleApprover by debounce function

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    It is necessary to add more unit tests in tests/unit/BaseSelectionListTest.tsx These tests would ensure keyboard navigation continues to work as intended and catch potential regressions early in the development cycle (avoid unexpected change as introducing shouldHighlightSelectedItem in #50541). I suggest adding these tests:

    • should initially focus the specified item by initiallyFocusedOptionKey
    • should update focus when shouldUpdateFocusedIndex is true and item is selected
    • should not update focus when shouldUpdateFocusedIndex is false
    • should handle keyboard navigation and update focus accordingly
    Pseudo Code (just drafted, need to adjust more in the PR phase)
            it('should initially focus the specified item by initiallyFocusedOptionKey', () => {
                const initialKey = '3';
                render(
                    <BaseListItemRenderer
                        sections={[{data: mockSections}]}
                        initiallyFocusedOptionKey={initialKey}
                    />,
                );
    
                // The item with key '3' should be focused
                const focusedItem = screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}3`);
                expect(focusedItem).toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
            });
    
            it('should update focus when shouldUpdateFocusedIndex is true and item is selected', () => {
                render(
                    <BaseListItemRenderer
                        sections={[{data: mockSections}]}
                        initiallyFocusedOptionKey="1"
                        shouldUpdateFocusedIndex
                    />,
                );
    
                // Initially item 1 is focused
                expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`))
                    .toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
    
                // Select item 3
                fireEvent.press(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}3`));
    
                // Item 3 should now be focused
                expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}3`))
                    .toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
                
                // Verify onArrowFocus was called with the correct item
                expect(onArrowFocusMock).toHaveBeenCalledWith(expect.objectContaining({
                    keyForList: '3'
                }));
            });
    
            it('should not update focus when shouldUpdateFocusedIndex is false', () => {
                render(
                    <BaseListItemRenderer
                        sections={[{data: mockSections}]}
                        initiallyFocusedOptionKey="1"
                        shouldUpdateFocusedIndex={false}
                    />,
                );
    
                // Initially item 1 is focused
                expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`))
                    .toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
    
                // Select item 3
                fireEvent.press(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}3`));
    
                // Item 1 should still be focused
                expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}1`))
                    .toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
                
                // Verify onArrowFocus was not called
                expect(onArrowFocusMock).not.toHaveBeenCalled();
            });
    
            it('should handle keyboard navigation and update focus accordingly', () => {
                render(
                    <BaseListItemRenderer
                        sections={[{data: mockSections}]}
                        initiallyFocusedOptionKey="1"
                        shouldUpdateFocusedIndex
                    />,
                );
    
                // Simulate pressing arrow down key
                fireEvent.keyDown(screen.getByTestId('selection-list'), { key: 'ArrowDown' });
    
                // Next item should be focused
                expect(screen.getByTestId(`${CONST.BASE_LIST_ITEM_TEST_ID}2`))
                    .toHaveProp('accessibilityState', expect.objectContaining({ focused: true }));
                
                // Verify onArrowFocus was called with the correct item
                expect(onArrowFocusMock).toHaveBeenCalledWith(expect.objectContaining({
                    keyForList: '2'
                }));
            });
    

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  8. added
    External
    on Mar 3, 2025
  9. changed the title [-]Workflows - Approver remains highlighted when navigating the list with keyboard[/-] [+][$250] Workflows - Approver remains highlighted when navigating the list with keyboard[/+] on Mar 3, 2025
  10. melvin-bot commented on Mar 3, 2025

    @melvin-bot
  11. added
    Help Wanted
    on Mar 3, 2025
  12. 38 remaining items

  13. added
    Weekly
    Awaiting Payment
    and removed
    Weekly
    on Apr 7, 2025
  14. changed the title [-][$250] Workflows - Approver remains highlighted when navigating the list with keyboard[/-] [+][Due for payment 2025-04-14] [$250] Workflows - Approver remains highlighted when navigating the list with keyboard[/+] on Apr 7, 2025
  15. removed
    Reviewing
    on Apr 7, 2025
  16. melvin-bot commented on Apr 7, 2025

    @melvin-bot

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

  17. melvin-bot commented on Apr 7, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.1.23-7 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 2025-04-14. 🎊

    For reference, here are some details about the assignees on this issue:

  18. melvin-bot commented on Apr 7, 2025

    @melvin-bot

    @dominictb @zanyrenney @dominictb The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  19. dominictb commented on Apr 8, 2025

    @dominictb
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] 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: https://github.com/Expensify/App/pull/50541/files#r2033071522

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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: NA

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    • Workspace has a few members
    • Workflows are enabled

    Test:

    1. Go to workspace settings > Workflows.
    2. Click on the existing workflow.
    3. Click Approver.
    4. Use down arrow to navigate the list
    5. Verify selected user is not highlighted and the highlighted background moves along with the currently focused user

    Do we agree 👍 or 👎

  20. added
    Daily
    and removed
    Weekly
    on Apr 14, 2025
  21. zanyrenney commented on Apr 14, 2025

    @zanyrenney
    Contributor
  22. zanyrenney commented on Apr 15, 2025

    @zanyrenney
    Contributor

    payment summary

    @dominictb requires payment automatic offer (Contributor) $250 paid via upwork.
    @thelullabyy requires payment automatic offer (Contributor) $250 paid via upwork.

  23. moved this from Bugs and Follow Up Issues to Done in #expensify-bugson Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions