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 2023-10-02] [$1000] Web- Action menu - Unable to navigate options in Action menu using Arrow keys #23280
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
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
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:
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:
Add useArrowKeyFocusManager to BaseReportActionContextMenu, e.g.:
constshouldEnableArrowNavigation=!props.isMini&&(props.isVisible||shouldKeepOpen);constfilteredContextMenuActions=_.filter(ContextMenuActions,shouldShowFilter);// Context menu actions that are not rendered as menu items are excluded from arrow navigationconstnonMenuItemActionIndexes=_.map(filteredContextMenuActions,(contextAction,index)=>_.isFunction(contextAction.renderContent) ? index : undefined);constdisabledIndexes=_.filter(nonMenuItemActionIndexes,(index)=>!_.isUndefined(index));const[focusedIndex,setFocusedIndex]=useArrowKeyFocusManager({initialFocusedIndex: -1,
disabledIndexes,maxIndex: filteredContextMenuActions.length-1,isActive: shouldEnableArrowNavigation,});
Add focused prop to ContextMenuItem (default false).
Inside ContextMenuItem, the focused prop should be passed down to MenuItem
Select the focused item on enter. For this, we abstract the onPress handler to a function.
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
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
};
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
melvin-bot commentedon Jul 20, 2023
Triggered auto assignment to @maddylewis (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Jul 20, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)samh-nl commentedon Jul 20, 2023
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
PopoverMenucomponent, which implements theuseArrowKeyFocusManagerhook to modify the focused menu index when the arrow keys are pressed:App/src/components/PopoverMenu/index.js
Line 44 in be2c81f
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:
useArrowKeyFocusManagertoBaseReportActionContextMenu, e.g.:focusedprop toContextMenuItem(default false).ContextMenuItem, the focused prop should be passed down toMenuItemWhat alternative solutions did you explore? (Optional)
N/A
[-]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[/+]melvin-bot commentedon Jul 21, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01eeba1242aba22472
melvin-bot commentedon Jul 21, 2023
Current assignee @maddylewis is eligible for the External assigner, not assigning anyone new.
melvin-bot commentedon Jul 21, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @0xmiroslav (
External)0xmiroslav commentedon Jul 21, 2023
@samh-nl can you please provide implementation detail? i.e. where to put useArrowKeyFocusManager in which component?
IftikharNadeem12 commentedon Jul 21, 2023
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();
}, []);
// Your chat component code with TouchableOpacity for each menu item
};
68 remaining items
maddylewis commentedon Oct 2, 2023
Payments
maddylewis commentedon Oct 2, 2023
@situchan will you review this checklist when you have a chance? #23280 (comment)
situchan commentedon Oct 2, 2023
This is kind of feature request than bug
situchan commentedon Oct 2, 2023
Regression Test Proposal (web/desktop only)
maddylewis commentedon Oct 2, 2023
offers sent 👍
situchan commentedon Oct 2, 2023
@maddylewis Accepted, thanks. Can you also please check bonus eligibility?
maddylewis commentedon Oct 2, 2023
included bonus
maddylewis commentedon Oct 2, 2023
@situchan - i think i paid you twice. i'll request a refund for the $1k payment.
situchan commentedon Oct 2, 2023
@maddylewis can we use that 1k for #24610 which is due payment for more than a month?
samh-nl commentedon Oct 2, 2023
Much appreciated, thanks.
maddylewis commentedon Oct 4, 2023
haha, yes for sure!
maddylewis commentedon Oct 4, 2023
confirmed here that the double payment can be used for the outstanding issue here - #24610