Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: apply style utility for unstable anchorPosition #42370

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

/** Should use style utility for anchor position */
blimpich marked this conversation as resolved.
Show resolved Hide resolved
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
Loading