From 31cdb29fc23270caea0513655408d6e4ff8788b7 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Tue, 19 Oct 2021 11:24:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Corrige=20un=20bug=20critique=20?= =?UTF-8?q?sur=20les=20anciennes=20versions=20de=20Safari?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tentative de correction basée sur le rapport Sentry, mais non testée. Voir #1790. --- .../source/components/utils/DisableAnimationContext.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mon-entreprise/source/components/utils/DisableAnimationContext.tsx b/mon-entreprise/source/components/utils/DisableAnimationContext.tsx index 193180943..41f88bd63 100644 --- a/mon-entreprise/source/components/utils/DisableAnimationContext.tsx +++ b/mon-entreprise/source/components/utils/DisableAnimationContext.tsx @@ -12,9 +12,11 @@ const useIsPrintContext = () => { const matchMediaPrint = window.matchMedia('print') setPrintContext(matchMediaPrint.matches) - matchMediaPrint.addEventListener('change', matchListener) + // `addEventListener` isn't supported by old versions of Safari and throws a + // fatal error. See #1790 and https://stackoverflow.com/a/56466334 + matchMediaPrint?.addEventListener('change', matchListener) return () => { - matchMediaPrint.removeEventListener('change', matchListener) + matchMediaPrint?.removeEventListener('change', matchListener) } }, [])