From fd8f0f5db262a64f85a9464f1433100bb820eb2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Mon, 25 Apr 2022 12:58:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Ignore=20canceling/dismissing=20?= =?UTF-8?q?share=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShareSimulationBanner/index.tsx | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/site/source/components/ShareSimulationBanner/index.tsx b/site/source/components/ShareSimulationBanner/index.tsx index e7903e6ae..649ffd6d2 100644 --- a/site/source/components/ShareSimulationBanner/index.tsx +++ b/site/source/components/ShareSimulationBanner/index.tsx @@ -57,14 +57,22 @@ export default function ShareOrSaveSimulationBanner({ const url = useUrl() const startSharing = async () => { if (shareAPIAvailable) { - await window.navigator.share({ - title: document.title, - text: t( - 'shareSimulation.navigatorShare', - 'Ma simulation Mon Entreprise' - ), - url, - }) + try { + await window.navigator.share({ + title: document.title, + text: t( + 'shareSimulation.navigatorShare', + 'Ma simulation Mon Entreprise' + ), + url, + }) + } catch (e) { + if (e instanceof Error && e.toString().includes('AbortError')) { + return + } + // eslint-disable-next-line no-console + console.error(e) + } } }