From 37049276548a48e8cb93692c54f8afe12ffdcaa2 Mon Sep 17 00:00:00 2001 From: stephenlago99 Date: Tue, 17 Sep 2024 14:49:01 +0300 Subject: [PATCH] Fix opening the customer portal link on Safari (#1737) --- src/pages/CustomerDetails.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/pages/CustomerDetails.tsx b/src/pages/CustomerDetails.tsx index e31106d66..86b82441f 100644 --- a/src/pages/CustomerDetails.tsx +++ b/src/pages/CustomerDetails.tsx @@ -121,18 +121,20 @@ const CustomerDetails = () => { // We open a window, add url then focus on different lines, in order to prevent browsers to block page opening // It could be seen as unexpected popup as not immediatly done on user action // https://stackoverflow.com/questions/2587677/avoid-browser-popup-blockers - const myWindow = window.open('', '_blank') - - if (myWindow?.location?.href) { - myWindow.location.href = generateCustomerPortalUrl.url - return myWindow?.focus() - } - - myWindow?.close() - addToast({ - severity: 'danger', - translateKey: 'text_62b31e1f6a5b8b1b745ece48', - }) + setTimeout(() => { + const myWindow = window.open('', '_blank') + + if (myWindow?.location?.href) { + myWindow.location.href = generateCustomerPortalUrl.url + return myWindow?.focus() + } + + myWindow?.close() + addToast({ + severity: 'danger', + translateKey: 'text_62b31e1f6a5b8b1b745ece48', + }) + }, 0) } }, })