From 23338eb4067c5420f6960657127223af6eed907b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 3 Oct 2023 00:42:39 +0700 Subject: [PATCH 1/2] Fix receipt image is opened in transaction thread report --- src/components/Attachments/AttachmentCarousel/index.js | 7 +++++-- .../Attachments/AttachmentCarousel/index.native.js | 6 ++++-- .../ReportActionCompose/AttachmentPickerWithMenuItems.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/index.js b/src/components/Attachments/AttachmentCarousel/index.js index 00b603cdd7d9..df6c812fde4e 100644 --- a/src/components/Attachments/AttachmentCarousel/index.js +++ b/src/components/Attachments/AttachmentCarousel/index.js @@ -37,17 +37,18 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl const [attachments, setAttachments] = useState([]); const [activeSource, setActiveSource] = useState(source); const [shouldShowArrows, setShouldShowArrows, autoHideArrows, cancelAutoHideArrows] = useCarouselArrows(); + const [isReceipt, setIsReceipt] = useState(false); const compareImage = useCallback( (attachment) => { - if (attachment.isReceipt) { + if (attachment.isReceipt && isReceipt) { const action = ReportActionsUtils.getParentReportAction(report); const transactionID = _.get(action, ['originalMessage', 'IOUTransactionID']); return attachment.transactionID === transactionID; } return attachment.source === source; }, - [source, report], + [source, report, isReceipt], ); useEffect(() => { @@ -86,10 +87,12 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, setDownl // to get the index of the current page const entry = _.first(viewableItems); if (!entry) { + setIsReceipt(false); setActiveSource(null); return; } + setIsReceipt(entry.item.isReceipt); setPage(entry.index); setActiveSource(entry.item.source); diff --git a/src/components/Attachments/AttachmentCarousel/index.native.js b/src/components/Attachments/AttachmentCarousel/index.native.js index bd12020341be..f2cdc111c666 100644 --- a/src/components/Attachments/AttachmentCarousel/index.native.js +++ b/src/components/Attachments/AttachmentCarousel/index.native.js @@ -27,17 +27,18 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose, const [activeSource, setActiveSource] = useState(source); const [isPinchGestureRunning, setIsPinchGestureRunning] = useState(true); const [shouldShowArrows, setShouldShowArrows, autoHideArrows, cancelAutoHideArrows] = useCarouselArrows(); + const [isReceipt, setIsReceipt] = useState(false); const compareImage = useCallback( (attachment) => { - if (attachment.isReceipt) { + if (attachment.isReceipt && isReceipt) { const action = ReportActionsUtils.getParentReportAction(report); const transactionID = _.get(action, ['originalMessage', 'IOUTransactionID']); return attachment.transactionID === transactionID; } return attachment.source === source; }, - [source, report], + [source, report, isReceipt], ); useEffect(() => { @@ -76,6 +77,7 @@ function AttachmentCarousel({report, reportActions, source, onNavigate, onClose, const item = attachments[newPageIndex]; setPage(newPageIndex); + setIsReceipt(item.isReceipt); setActiveSource(item.source); onNavigate(item); diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js index 6dd3355f4a53..10f29615c904 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js @@ -243,7 +243,7 @@ function AttachmentPickerWithMenuItems({ onAddActionPressed(); // Drop focus to avoid blue focus ring. - actionButtonRef.current.blur(); + // actionButtonRef.current.blur(); setMenuVisibility(!isMenuVisible); }} style={styles.composerSizeButton} From 09f3a5f73b343a93282da0ab747c4db7be3a5148 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 3 Oct 2023 10:40:30 +0700 Subject: [PATCH 2/2] restore hard code --- .../report/ReportActionCompose/AttachmentPickerWithMenuItems.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js index 10f29615c904..6dd3355f4a53 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js @@ -243,7 +243,7 @@ function AttachmentPickerWithMenuItems({ onAddActionPressed(); // Drop focus to avoid blue focus ring. - // actionButtonRef.current.blur(); + actionButtonRef.current.blur(); setMenuVisibility(!isMenuVisible); }} style={styles.composerSizeButton}