Skip to content

Commit

Permalink
Merge pull request #48375 from daledah/fix/47743
Browse files Browse the repository at this point in the history
fix: prevent open context menu on money request
  • Loading branch information
lakchote committed Sep 24, 2024
2 parents 1c39bd2 + 9c7b035 commit accea60
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
59 changes: 37 additions & 22 deletions src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import PDFThumbnail from './PDFThumbnail';
import PressableWithoutFocus from './Pressable/PressableWithoutFocus';
import ReceiptEmptyState from './ReceiptEmptyState';
import ReceiptImage from './ReceiptImage';
import {ShowContextMenuContext} from './ShowContextMenuContext';
import ShowMoreButton from './ShowMoreButton';

type MoneyRequestConfirmationListFooterProps = {
Expand Down Expand Up @@ -268,6 +269,18 @@ function MoneyRequestConfirmationListFooter({
const resolvedThumbnail = isLocalFile ? receiptThumbnail : tryResolveUrlFromApiRoot(receiptThumbnail ?? '');
const resolvedReceiptImage = isLocalFile ? receiptImage : tryResolveUrlFromApiRoot(receiptImage ?? '');

const contextMenuContextValue = useMemo(
() => ({
anchor: null,
report: undefined,
reportNameValuePairs: undefined,
action: undefined,
checkIfContextMenuActive: () => {},
isDisabled: true,
}),
[],
);

const mentionReportContextValue = useMemo(() => ({currentReportID: reportID}), [reportID]);

// An intermediate structure that helps us classify the fields as "primary" and "supplementary".
Expand Down Expand Up @@ -300,29 +313,31 @@ function MoneyRequestConfirmationListFooter({
},
{
item: (
<MentionReportContext.Provider
key={translate('common.description')}
value={mentionReportContextValue}
>
<MenuItemWithTopDescription
<ShowContextMenuContext.Provider value={contextMenuContextValue}>
<MentionReportContext.Provider
key={translate('common.description')}
shouldShowRightIcon={!isReadOnly}
shouldParseTitle
excludedMarkdownRules={!policy ? ['reportMentions'] : []}
title={iouComment}
description={translate('common.description')}
onPress={() => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
numberOfLinesTitle={2}
/>
</MentionReportContext.Provider>
value={mentionReportContextValue}
>
<MenuItemWithTopDescription
key={translate('common.description')}
shouldShowRightIcon={!isReadOnly}
shouldParseTitle
excludedMarkdownRules={!policy ? ['reportMentions'] : []}
title={iouComment}
description={translate('common.description')}
onPress={() => {
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRouteWithoutParams(), reportActionID),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
numberOfLinesTitle={2}
/>
</MentionReportContext.Provider>
</ShowContextMenuContext.Provider>
),
shouldShow: true,
isSupplementary: false,
Expand Down
6 changes: 4 additions & 2 deletions src/pages/home/report/ReportActionItemContentCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ function ReportActionItemContentCreated({contextValue, parentReportAction, trans
[shouldHideThreadDividerLine, report.reportID, styles.reportHorizontalRule],
);

const contextMenuValue = useMemo(() => ({...contextValue, isDisabled: true}), [contextValue]);

if (ReportActionsUtils.isTransactionThread(parentReportAction)) {
const isReversedTransaction = ReportActionsUtils.isReversedTransaction(parentReportAction);

Expand Down Expand Up @@ -104,7 +106,7 @@ function ReportActionItemContentCreated({contextValue, parentReportAction, trans
}

return (
<ShowContextMenuContext.Provider value={contextValue}>
<ShowContextMenuContext.Provider value={contextMenuValue}>
<View>
<MoneyRequestView
report={report}
Expand Down Expand Up @@ -158,7 +160,7 @@ function ReportActionItemContentCreated({contextValue, parentReportAction, trans
shouldShowTotal={transaction ? transactionCurrency !== report.currency : false}
shouldHideThreadDividerLine={shouldHideThreadDividerLine}
/>
<ShowContextMenuContext.Provider value={contextValue}>
<ShowContextMenuContext.Provider value={contextMenuValue}>
<View>
<MoneyRequestView
report={transactionThreadReport}
Expand Down

0 comments on commit accea60

Please sign in to comment.