From 661347a700e5e6402e5fb428471f09d0f79d0fc1 Mon Sep 17 00:00:00 2001 From: Tom Van Dort Date: Wed, 23 Oct 2024 14:35:16 -0400 Subject: [PATCH] FIDES-1429: Safari < 14 support (#5410) --- clients/fides-js/src/lib/hooks/useMediaQuery.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/clients/fides-js/src/lib/hooks/useMediaQuery.ts b/clients/fides-js/src/lib/hooks/useMediaQuery.ts index 87e00d6dda..d89aa32e00 100644 --- a/clients/fides-js/src/lib/hooks/useMediaQuery.ts +++ b/clients/fides-js/src/lib/hooks/useMediaQuery.ts @@ -14,9 +14,21 @@ export const useMediaQuery = (query: string) => { function handleChange(e: MediaQueryListEvent) { setMatches(e.matches); } - matchQueryList.addEventListener("change", handleChange); + + if (matchQueryList.addEventListener) { + matchQueryList.addEventListener("change", handleChange); + } else { + // Older browser and test automation supportSafari < 14 + matchQueryList.addListener(handleChange); + } + return () => { - matchQueryList.removeEventListener("change", handleChange); + if (matchQueryList.removeEventListener) { + matchQueryList.removeEventListener("change", handleChange); + } else { + // Older browser and test automation support + matchQueryList.removeListener(handleChange); + } }; }, [query]); return matches;