Skip to content

[HOLD for payment 2023-10-02] [$1000] Web- Action menu - Unable to navigate options in Action menu using Arrow keys #23280

Closed

Description

@kbecciv

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. Go to site
  2. Open a conversation
  3. Click on a chat
  4. Open action menu
  5. Use arrow keys and TAB to navigate
  6. Tap FAB
  7. Use Arrow Keys and TAB to navigate

Expected Result:

Like in FAB, user must be able to navigate using both arrow keys and TAB button.

Actual Result:

On pressing FAB, user can navigate through options using both arrow keys and TAB button. In Action Menu, user can navigate only using TAB . He cannot use arrow keys and navigate through options in Action menu,

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.3.43-3
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

Bug6135278_tab.mp4

Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01eeba1242aba22472
  • Upwork Job ID: 1682468481034489856
  • Last Price Increase: 2023-07-21
  • Automatic offers:
    • situchan | Contributor | 26241505
    • samh-nl | Contributor | 26748431

Activity

  1. added
    Daily
    Bug
    on Jul 20, 2023
  2. melvin-bot commented on Jul 20, 2023

    @melvin-bot

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

  3. melvin-bot commented on Jul 20, 2023

    @melvin-bot

    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
  4. samh-nl commented on Jul 20, 2023

    @samh-nl
    Contributor

    Proposal

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

    The report action context menu cannot be navigated through the arrow keys, while the FAB can.

    What is the root cause of that problem?

    The FAB relies on the PopoverMenu component, which implements the useArrowKeyFocusManager hook to modify the focused menu index when the arrow keys are pressed:

    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({initialFocusedIndex: -1, maxIndex: props.menuItems.length - 1, isActive: props.isVisible});

    However, the context menu of report actions does not implement such functionality.

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

    Similar to the FAB, the arrow keys should be registered and used to determine the focused menu item.

    This involves the following changes:

    1. Add useArrowKeyFocusManager to BaseReportActionContextMenu, e.g.:
    const shouldEnableArrowNavigation = !props.isMini && (props.isVisible || shouldKeepOpen);
    const filteredContextMenuActions = _.filter(ContextMenuActions, shouldShowFilter);
    
    // Context menu actions that are not rendered as menu items are excluded from arrow navigation
    const nonMenuItemActionIndexes = _.map(filteredContextMenuActions, (contextAction, index) => _.isFunction(contextAction.renderContent) ? index : undefined);
    const disabledIndexes = _.filter(nonMenuItemActionIndexes, (index) => !_.isUndefined(index));
    
    const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({
        initialFocusedIndex: -1,
        disabledIndexes,
        maxIndex: filteredContextMenuActions.length - 1,
        isActive: shouldEnableArrowNavigation,
    });
    1. Add focused prop to ContextMenuItem (default false).
    2. Inside ContextMenuItem, the focused prop should be passed down to MenuItem
    3. Select the focused item on enter. For this, we abstract the onPress handler to a function.
    const selectItem = (contextAction) => {
        interceptAnonymousUser(() => contextAction.onPress(closePopup, payload), contextAction.isAnonymousAction);
    };
    
    useKeyboardShortcut(
    	CONST.KEYBOARD_SHORTCUTS.ENTER,
    	() => {
    		if (focusedIndex === -1) {
    			return;
    		}
    		selectItem(filteredContextMenuActions[focusedIndex]);
    		setFocusedIndex(-1);
    	},
            {isActive: shouldEnableArrowNavigation},
    );

    What alternative solutions did you explore? (Optional)

    N/A

  5. added
    External
    on Jul 21, 2023
  6. changed the title [-]Web- Action menu - Unable to navigate options in Action menu using Arrow keys[/-] [+][$1000] Web- Action menu - Unable to navigate options in Action menu using Arrow keys[/+] on Jul 21, 2023
  7. melvin-bot commented on Jul 21, 2023

    @melvin-bot
  8. added
    Help Wanted
    on Jul 21, 2023
  9. melvin-bot commented on Jul 21, 2023

    @melvin-bot

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

  10. melvin-bot commented on Jul 21, 2023

    @melvin-bot

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

  11. 0xmiroslav commented on Jul 21, 2023

    @0xmiroslav
    Contributor

    @samh-nl can you please provide implementation detail? i.e. where to put useArrowKeyFocusManager in which component?

  12. IftikharNadeem12 commented on Jul 21, 2023

    @IftikharNadeem12

    import React, { useRef, useEffect } from 'react';
    import { View, TouchableOpacity, Text, Keyboard } from 'react-native';

    const ChatComponent = () => {
    const item1Ref = useRef(null);
    const item2Ref = useRef(null);
    // Add more refs for other menu items if needed

    useEffect(() => {
    const handleArrowKeyPress = (event) => {
    if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
    // Prevent default arrow key behavior, such as scrolling
    event.preventDefault();

        // Get the currently focused element
        const currentlyFocusedItem = item1Ref.current || item2Ref.current;
        if (!currentlyFocusedItem) return;
    
        // Find the next focusable element based on the Arrow key pressed
        const nextFocusableItem = event.key === 'ArrowDown' ? item2Ref.current : item1Ref.current;
    
        // Focus the next element
        if (nextFocusableItem) {
          nextFocusableItem.focus();
        }
      }
    };
    
    // Add event listener for keydown
    Keyboard.addListener('keydown', handleArrowKeyPress);
    
    // Clean up the event listener on component unmount
    return () => {
      Keyboard.removeListener('keydown', handleArrowKeyPress);
    };
    

    }, []);

    // Your chat component code with TouchableOpacity for each menu item
    };

  13. 68 remaining items

  14. added
    Daily
    and removed
    Weekly
    on Oct 1, 2023
  15. maddylewis commented on Oct 2, 2023

    @maddylewis
    Contributor

    Payments

    • Reporting bonus: N/A
    • Contributor: @samh-nl ($1k via Upwork)
    • C+: @situchan ($1k via Upwork)
  16. maddylewis commented on Oct 2, 2023

    @maddylewis
    Contributor

    @situchan will you review this checklist when you have a chance? #23280 (comment)

  17. situchan commented on Oct 2, 2023

    @situchan
    Contributor

    This is kind of feature request than bug

  18. situchan commented on Oct 2, 2023

    @situchan
    Contributor

    Regression Test Proposal (web/desktop only)

    1. Go to any chat that has a message
    2. Right-click the message
    3. Verify that context menu opens
    4. Repeat pressing up/down arrows from keyboard
    5. Verify that selected option changes based on arrow key
    6. Verify that first option is selected on Down press when last option is selected
    7. Verify that last option is selected on Upon press when first option is selected
    8. Press Enter on any selected option
    9. Verify that it triggers action of selected option correctly and context menu closes
  19. maddylewis commented on Oct 2, 2023

    @maddylewis
    Contributor

    offers sent 👍

  20. situchan commented on Oct 2, 2023

    @situchan
    Contributor

    @maddylewis Accepted, thanks. Can you also please check bonus eligibility?

  21. maddylewis commented on Oct 2, 2023

    @maddylewis
    Contributor

    included bonus

  22. maddylewis commented on Oct 2, 2023

    @maddylewis
    Contributor

    @situchan - i think i paid you twice. i'll request a refund for the $1k payment.

  23. situchan commented on Oct 2, 2023

    @situchan
    Contributor

    @maddylewis can we use that 1k for #24610 which is due payment for more than a month?

  24. samh-nl commented on Oct 2, 2023

    @samh-nl
    Contributor

    Much appreciated, thanks.

  25. maddylewis commented on Oct 4, 2023

    @maddylewis
    Contributor

    haha, yes for sure!

  26. maddylewis commented on Oct 4, 2023

    @maddylewis
    Contributor

    confirmed here that the double payment can be used for the outstanding issue here - #24610

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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions