From 299a42e622f071ddfd3c06c00a3bf50e47eff230 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Sat, 6 Jul 2024 18:45:49 +0530 Subject: [PATCH] mWeb/Safari - Attachments - New tab doesn't open when clicking the download button from the overflow menu on a .doc file. Signed-off-by: Krishna Gupta --- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index 43ba70d0ffcf..8f130a5546d8 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -10,6 +10,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MiniQuickEmojiReactions from '@components/Reactions/MiniQuickEmojiReactions'; import QuickEmojiReactions from '@components/Reactions/QuickEmojiReactions'; import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; +import * as Browser from '@libs/Browser'; import Clipboard from '@libs/Clipboard'; import EmailUtils from '@libs/EmailUtils'; import * as Environment from '@libs/Environment/Environment'; @@ -514,7 +515,9 @@ const ContextMenuActions: ContextMenuAction[] = [ const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL ?? ''); const sourceID = (sourceURL?.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1]; Download.setDownload(sourceID, true); - fileDownload(sourceURLWithAuth, originalFileName ?? '').then(() => Download.setDownload(sourceID, false)); + const anchorRegex = CONST.REGEX_LINK_IN_ANCHOR; + const isAnchorTag = anchorRegex.test(html); + fileDownload(sourceURLWithAuth, originalFileName ?? '', '', isAnchorTag && Browser.isMobileSafari()).then(() => Download.setDownload(sourceID, false)); if (closePopover) { hideContextMenu(true, ReportActionComposeFocusManager.focus); }