Skip to content

Commit

Permalink
FIDES-1429: Safari < 14 support (#5410)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvandort authored Oct 23, 2024
1 parent 5547ece commit 661347a
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions clients/fides-js/src/lib/hooks/useMediaQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 661347a

Please sign in to comment.