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: Android-Accounting-Export button with dropdown goes out of preview component while loading #54852

Merged
8 changes: 6 additions & 2 deletions src/components/ReportActionItem/ExportWithDropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useCallback, useMemo, useState} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu';
Expand Down Expand Up @@ -27,6 +28,8 @@ type ExportWithDropdownMenuProps = {
connectionName: ConnectionName;

dropdownAnchorAlignment?: AnchorAlignment;

wrapperStyle?: StyleProp<ViewStyle>;
};

function ExportWithDropdownMenu({
Expand All @@ -37,6 +40,7 @@ function ExportWithDropdownMenu({
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP,
},
wrapperStyle,
}: ExportWithDropdownMenuProps) {
const reportID = report?.reportID;
const styles = useThemeStyles();
Expand Down Expand Up @@ -72,7 +76,7 @@ function ExportWithDropdownMenu({
...optionTemplate,
},
];
const exportMethod = exportMethods?.[report?.policyID ?? ''] ?? null;
const exportMethod = report?.policyID && exportMethods ? exportMethods[report.policyID] : null;
wildan-m marked this conversation as resolved.
Show resolved Hide resolved
if (exportMethod) {
options.sort((method) => (method.value === exportMethod ? -1 : 0));
}
Expand Down Expand Up @@ -124,7 +128,7 @@ function ExportWithDropdownMenu({
onOptionSelected={({value}) => savePreferredExportMethod(value)}
options={dropdownOptions}
style={[shouldUseNarrowLayout && styles.flexGrow1]}
wrapperStyle={styles.flex1}
wrapperStyle={[styles.flex1, wrapperStyle]}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we are using StyleProp<ViewStyle> type, is array value to wrapperStyle prop supported? Will it work with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parasharrajat the style has been flattened

buttonSize={CONST.DROPDOWN_BUTTON_SIZE.MEDIUM}
/>
<ConfirmModal
Expand Down
1 change: 1 addition & 0 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ function ReportPreview({
policy={policy}
report={iouReport}
connectionName={connectedIntegration}
wrapperStyle={styles.flexReset}
dropdownAnchorAlignment={{
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT,
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
Expand Down
Loading