Skip to content

Commit b6b66f6

Browse files
authored
Merge pull request Expensify#79319 from daledah/fix/78944
fix: quickly tapping a workspace row and the 3‑dot button
2 parents 8ab69fc + ea5718f commit b6b66f6

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/components/ThreeDotsMenu/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function ThreeDotsMenu({
4545
shouldSelfPosition = false,
4646
threeDotsMenuRef,
4747
sentryLabel,
48+
isContainerFocused = true,
4849
}: ThreeDotsMenuProps) {
4950
const [modal] = useOnyx(ONYXKEYS.MODAL, {canBeMissing: true});
5051

@@ -100,13 +101,12 @@ function ThreeDotsMenu({
100101
hidePopoverMenu,
101102
onThreeDotsPress,
102103
}));
103-
104104
useEffect(() => {
105-
if (!isBehindModal || !isPopupMenuVisible) {
105+
if ((!isBehindModal || !isPopupMenuVisible) && isContainerFocused) {
106106
return;
107107
}
108108
hidePopoverMenu();
109-
}, [hidePopoverMenu, isBehindModal, isPopupMenuVisible]);
109+
}, [hidePopoverMenu, isBehindModal, isPopupMenuVisible, isContainerFocused]);
110110

111111
useLayoutEffect(() => {
112112
if (!getMenuPosition || !isPopupMenuVisible) {
@@ -166,7 +166,7 @@ function ThreeDotsMenu({
166166
<PopoverMenu
167167
onClose={hidePopoverMenu}
168168
onModalHide={() => setRestoreFocusType(undefined)}
169-
isVisible={isPopupMenuVisible && !isBehindModal}
169+
isVisible={isPopupMenuVisible && !isBehindModal && isContainerFocused}
170170
anchorPosition={position ?? anchorPosition ?? {horizontal: 0, vertical: 0}}
171171
anchorAlignment={anchorAlignment}
172172
onItemSelected={(item) => {

src/components/ThreeDotsMenu/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ type ThreeDotsMenuProps = WithSentryLabel & {
5151

5252
/** Ref to the menu */
5353
threeDotsMenuRef?: React.RefObject<{hidePopoverMenu: () => void; isPopupMenuVisible: boolean} | null>;
54+
55+
/** Whether the menu is focused */
56+
isContainerFocused?: boolean;
5457
};
5558

5659
type ThreeDotsMenuWithOptionalAnchorProps =

src/pages/workspace/WorkspacesListRow.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useIsFocused} from '@react-navigation/native';
12
import {Str} from 'expensify-common';
23
import React, {useCallback, useEffect, useRef} from 'react';
34
import {View} from 'react-native';
@@ -126,6 +127,7 @@ function WorkspacesListRow({
126127
const {translate} = useLocalize();
127128
const {shouldUseNarrowLayout} = useResponsiveLayout();
128129
const theme = useTheme();
130+
const isFocused = useIsFocused();
129131
const isNarrow = layoutWidth === CONST.LAYOUT_WIDTH.NARROW;
130132
const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'Hourglass']);
131133
const illustrations = useMemoizedLazyIllustrations(['Mailbox', 'ShieldYellow']);
@@ -208,6 +210,7 @@ function WorkspacesListRow({
208210
<BrickRoadIndicatorIcon brickRoadIndicator={brickRoadIndicator} />
209211
</View>
210212
<ThreeDotsMenu
213+
isContainerFocused={isFocused}
211214
shouldSelfPosition
212215
menuItems={menuItems}
213216
anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}}

0 commit comments

Comments
 (0)