Skip to content

Commit dc57aa7

Browse files
MelvinBothungvu193
andcommitted
Fix: enable right-click context menu on Tab Selector via secondaryInteraction
Co-authored-by: Hans Vu <hungvu193@users.noreply.github.com>
1 parent 119b819 commit dc57aa7

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/components/TabSelector/TabSelectorItem.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Badge from '@components/Badge';
2-
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
2+
import PressableWithSecondaryInteraction from '@components/PressableWithSecondaryInteraction';
33
import Tooltip from '@components/Tooltip';
44

55
import useNetwork from '@hooks/useNetwork';
@@ -17,7 +17,10 @@ import TabIcon from './TabIcon';
1717
import TabLabel from './TabLabel';
1818
import {useTabSelectorActions} from './TabSelectorContext';
1919

20-
const AnimatedPressableWithFeedback = Animated.createAnimatedComponent(PressableWithFeedback);
20+
// Use PressableWithSecondaryInteraction so the tab responds to both a long-press (touch) and a
21+
// right-click / context-menu (web). PressableWithFeedback's onLongPress alone never fires on a
22+
// right-click, so the desktop-web menu could not be opened.
23+
const AnimatedPressableWithSecondaryInteraction = Animated.createAnimatedComponent(PressableWithSecondaryInteraction);
2124

2225
type TabSelectorItemProps = BaseTabSelectorItemProps;
2326

@@ -55,7 +58,7 @@ function TabSelectorItem({
5558
const shouldTextHaveStrikeThrough = isOffline && pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
5659

5760
const children = (
58-
<AnimatedPressableWithFeedback
61+
<AnimatedPressableWithSecondaryInteraction
5962
accessibilityLabel={title}
6063
accessibilityState={accessibilityState}
6164
accessibilityRole={CONST.ROLE.TAB}
@@ -66,7 +69,7 @@ function TabSelectorItem({
6669
isOfflineWithPendingAction ? styles.offlineFeedbackPending : undefined,
6770
]}
6871
wrapperStyle={equalWidth ? styles.flex1 : styles.flexGrow1}
69-
onLongPress={onLongPress}
72+
onSecondaryInteraction={onLongPress}
7073
onPress={() => {
7174
scrollToTab(tabKey);
7275
onPress();
@@ -102,7 +105,7 @@ function TabSelectorItem({
102105
badgeStyles={badgeStyles}
103106
/>
104107
)}
105-
</AnimatedPressableWithFeedback>
108+
</AnimatedPressableWithSecondaryInteraction>
106109
);
107110

108111
return (

0 commit comments

Comments
 (0)