Skip to content

Commit 3acd370

Browse files
committed
set popoverAnchorRefs
1 parent 27a91cd commit 3acd370

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

src/components/ConnectToNetSuiteFlow/index.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ function ConnectToNetSuiteFlow({policyID}: ConnectToNetSuiteFlowProps) {
1818
const {translate} = useLocalize();
1919

2020
const hasPoliciesConnectedToNetSuite = !!getAdminPoliciesConnectedToNetSuite()?.length;
21-
const {shouldUseNarrowLayout} = useResponsiveLayout();
21+
22+
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to use the correct modal type
23+
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
24+
const {isSmallScreenWidth} = useResponsiveLayout();
25+
2226
const [isReuseConnectionsPopoverOpen, setIsReuseConnectionsPopoverOpen] = useState(false);
2327
const [reuseConnectionPopoverPosition, setReuseConnectionPopoverPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
2428
const {popoverAnchorRefs} = useAccountingContext();
@@ -57,7 +61,7 @@ function ConnectToNetSuiteFlow({policyID}: ConnectToNetSuiteFlowProps) {
5761
}, []);
5862

5963
if (threeDotsMenuContainerRef) {
60-
if (!shouldUseNarrowLayout) {
64+
if (!isSmallScreenWidth) {
6165
threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => {
6266
const horizontal = x + width;
6367
const vertical = y + height;

src/components/MenuItem.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {ImageContentFit} from 'expo-image';
2-
import type {ReactElement, ReactNode} from 'react';
2+
import type {ReactElement, ReactNode, Ref} from 'react';
33
import React, {forwardRef, useContext, useMemo} from 'react';
44
import type {GestureResponderEvent, StyleProp, TextStyle, ViewStyle} from 'react-native';
55
import {ActivityIndicator, View} from 'react-native';
@@ -60,6 +60,9 @@ type NoIcon = {
6060
};
6161

6262
type MenuItemBaseProps = {
63+
/* View ref */
64+
ref?: Ref<View>;
65+
6366
/** Function to fire when component is pressed */
6467
onPress?: (event: GestureResponderEvent | KeyboardEvent) => void | Promise<void>;
6568

src/pages/workspace/accounting/MultiConnectionSelectorPage.tsx

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {title} from 'process';
22
import React, {useMemo} from 'react';
3+
import {View} from 'react-native';
34
import {ValueOf} from 'type-fest';
45
import HeaderWithBackButton from '@components/HeaderWithBackButton';
56
import Icon from '@components/Icon';
@@ -38,7 +39,6 @@ function MultiConnectionSelectorPage({policy, route}: MultiConnectionSelectorPag
3839
const {translate} = useLocalize();
3940
const styles = useThemeStyles();
4041

41-
// s77rt: set popoverAnchorRefs
4242
const {startIntegrationFlow, popoverAnchorRefs} = useAccountingContext();
4343

4444
const integrations = CONST.POLICY.CONNECTIONS.MULTI_CONNECTIONS_MAPPING_INVERTED[multiConnectionName] ?? [];
@@ -65,6 +65,14 @@ function MultiConnectionSelectorPage({policy, route}: MultiConnectionSelectorPag
6565
//shouldDisconnectIntegrationBeforeConnecting: true,
6666
});
6767
},
68+
ref: (ref) => {
69+
if (!popoverAnchorRefs?.current) {
70+
return;
71+
}
72+
73+
// eslint-disable-next-line react-compiler/react-compiler
74+
popoverAnchorRefs.current[integration].current = ref;
75+
},
6876
};
6977

7078
return connectionsMenuItem;
@@ -88,11 +96,13 @@ function MultiConnectionSelectorPage({policy, route}: MultiConnectionSelectorPag
8896
shouldShowOfflineIndicatorInWideScreen
8997
>
9098
<HeaderWithBackButton title={translate(`workspace.multiConnectionSelector.title`, {connectionName: multiConnectionName})} />
91-
<Text style={[styles.ph5, styles.pt3, styles.mb5]}>{translate(`workspace.multiConnectionSelector.description`, {connectionName: multiConnectionName})}</Text>
92-
<MenuItemList
93-
menuItems={connectionsMenuItems}
94-
shouldUseSingleExecution
95-
/>
99+
<View style={[styles.flexGrow1]}>
100+
<Text style={[styles.mb5, styles.ph5, styles.pt3]}>{translate(`workspace.multiConnectionSelector.description`, {connectionName: multiConnectionName})}</Text>
101+
<MenuItemList
102+
menuItems={connectionsMenuItems}
103+
shouldUseSingleExecution
104+
/>
105+
</View>
96106
</ScreenWrapper>
97107
</AccessOrNotFoundWrapper>
98108
);

0 commit comments

Comments
 (0)