Skip to content

Commit

Permalink
Fix position of three dots menu
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejSWM committed Jan 3, 2024
1 parent 7152549 commit 0f89d72
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/pages/workspace/WorkspacesListRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useMemo} from 'react';
import {debounce} from 'lodash';
import React, {useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
import {ValueOf} from 'type-fest';
import Avatar from '@components/Avatar';
Expand All @@ -10,9 +11,9 @@ import ThreeDotsMenu from '@components/ThreeDotsMenu';
import withCurrentUserPersonalDetails, {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import {AvatarSource} from '@libs/UserUtils';
import {AnchorPosition} from '@styles/index';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import IconAsset from '@src/types/utils/IconAsset';
Expand Down Expand Up @@ -66,7 +67,8 @@ function WorkspacesListRow({
}: WorkspacesListRowProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {windowWidth} = useWindowDimensions();
const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
const threeDotsMenuContainerRef = useRef<View>(null);

const ownerDetails = ownerAccountID && PersonalDetailsUtils.getPersonalDetailsByIDs([ownerAccountID], currentUserPersonalDetails.accountID)[0];

Expand Down Expand Up @@ -164,12 +166,23 @@ function WorkspacesListRow({
</View>
</View>
{isWide && (
<ThreeDotsMenu
menuItems={menuItems}
anchorPosition={styles.threeDotsPopoverOffset(windowWidth)}
iconStyles={[styles.mr2]}
shouldOverlay
/>
<View ref={threeDotsMenuContainerRef}>
<ThreeDotsMenu
onIconPress={() => {
threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => {
setThreeDotsMenuPosition({
horizontal: x,
vertical: y + height + variables.componentBorderRadiusSmall,
});
});
}}
menuItems={menuItems}
anchorPosition={threeDotsMenuPosition}
anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}}
iconStyles={[styles.mr2]}
shouldOverlay
/>
</View>
)}
</View>
);
Expand Down

0 comments on commit 0f89d72

Please sign in to comment.