From d960b1da20601b27e7c89448b7a343e1ae11ff5b Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Mon, 2 Nov 2020 15:44:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Corrige=20la=20disparition=20du?= =?UTF-8?q?=20widget=20covid=20quand=20on=20quitte=20la=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Simulateurs/ChômagePartiel.tsx | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx index e6c011f0c..07e8b4e2c 100644 --- a/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx +++ b/mon-entreprise/source/sites/mon-entreprise.fr/pages/Simulateurs/ChômagePartiel.tsx @@ -16,8 +16,11 @@ declare global { StonlyWidget?: { open: () => void close: () => void + toggle: () => void launcherShow: () => void launcherHide: () => void + startURLWatcher: () => void + stopURLWatcher: () => void } } } @@ -28,15 +31,18 @@ export default function ChômagePartiel() { if (inIframe) { return } - const script = document.createElement('script') - window.STONLY_WID = '0128ae02-6780-11ea-ac13-0a4250848ba4' - script.src = 'https://stonly.com/js/widget/stonly-widget.js' - script.async = true - document.body.appendChild(script) - window.StonlyWidget?.launcherShow() + if (!window.StonlyWidget) { + const script = document.createElement('script') + window.STONLY_WID = '0128ae02-6780-11ea-ac13-0a4250848ba4' + script.src = 'https://stonly.com/js/widget/stonly-widget.js' + script.async = true + document.body.appendChild(script) + } else { + window.StonlyWidget?.launcherShow() + } return () => { + window.StonlyWidget?.stopURLWatcher() window.StonlyWidget?.launcherHide() - document.body.removeChild(script) } }, [inIframe]) return (