Skip to content

Commit

Permalink
Merge pull request #42370 from dragnoir/40944-fix
Browse files Browse the repository at this point in the history
Fix: apply style utility for unstable anchorPosition
  • Loading branch information
puneetlath authored May 27, 2024
2 parents 50ec4d5 + f586090 commit 077297e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/AvatarWithImagePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ type AvatarWithImagePickerProps = {

/** Optionally override the default "Edit" icon */
editIcon?: IconAsset;

/** Determines if a style utility function should be used for calculating the PopoverMenu anchor position. */
shouldUseStyleUtilityForAnchorPosition?: boolean;
};

function AvatarWithImagePicker({
Expand Down Expand Up @@ -152,6 +155,7 @@ function AvatarWithImagePicker({
enablePreview = false,
shouldDisableViewPhoto = false,
editIcon = Expensicons.Pencil,
shouldUseStyleUtilityForAnchorPosition = false,
}: AvatarWithImagePickerProps) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -393,7 +397,7 @@ function AvatarWithImagePicker({
}
}}
menuItems={menuItems}
anchorPosition={popoverPosition}
anchorPosition={shouldUseStyleUtilityForAnchorPosition ? styles.popoverMenuOffset(windowWidth) : popoverPosition}
anchorAlignment={{horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.LEFT, vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP}}
withoutOverlay
anchorRef={anchorRef}
Expand Down
1 change: 1 addition & 0 deletions src/pages/NewChatConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
shouldDisableViewPhoto
editIcon={Expensicons.Camera}
editIconStyle={styles.smallEditIconAccount}
shouldUseStyleUtilityForAnchorPosition
/>
</View>
<MenuItemWithTopDescription
Expand Down
1 change: 1 addition & 0 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
errors={report.errorFields?.avatar ?? null}
errorRowStyles={styles.mt6}
onErrorClose={() => Report.clearAvatarErrors(report.reportID ?? '')}
shouldUseStyleUtilityForAnchorPosition
/>
) : (
<RoomHeaderAvatars
Expand Down
6 changes: 6 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3519,6 +3519,12 @@ const styles = (theme: ThemeColors) =>
horizontal: windowWidth - 140,
} satisfies AnchorPosition),

popoverMenuOffset: (windowWidth: number) =>
({
...getPopOverVerticalOffset(180),
horizontal: windowWidth - 355,
} satisfies AnchorPosition),

iPhoneXSafeArea: {
backgroundColor: theme.inverse,
flex: 1,
Expand Down

0 comments on commit 077297e

Please sign in to comment.