Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari 13 support, or at least graceful error handling? #152

Closed
kostia1st opened this issue May 24, 2023 · 3 comments · Fixed by #156
Closed

Safari 13 support, or at least graceful error handling? #152

kostia1st opened this issue May 24, 2023 · 3 comments · Fixed by #156
Labels
bug Something isn't working

Comments

@kostia1st
Copy link
Contributor

kostia1st commented May 24, 2023

Currently, in Safari 13 react-collapsed generates an error

TypeError: mediaQueryList.addEventListener is not a function. 
(In 'mediaQueryList.addEventListener("change", listener)', 'mediaQueryList.addEventListener' is undefined)

I seem to have managed to track it down to

function usePrefersReducedMotion() {
  const [prefersReducedMotion, setPrefersReducedMotion] = useState2(false);
  useEffect3(() => {
    const mediaQueryList = window.matchMedia(QUERY);
    setPrefersReducedMotion(mediaQueryList.matches);
    const listener = (event) => {
      setPrefersReducedMotion(event.matches);
    };
    mediaQueryList.addEventListener("change", listener);
    return () => {
      mediaQueryList.removeEventListener("change", listener);
    };
  }, []);
  return prefersReducedMotion;
}
@roginfarrer roginfarrer added the bug Something isn't working label May 24, 2023
@kostia1st
Copy link
Contributor Author

Just a kind reminder - will this issue be fixed?

PS: PRs for the repo aren't going anywhere either. And I personally don't like the idea of forking the repo just for the purpose of one fix, losing any potential future maintenance benefits. Hence the question

@roginfarrer
Copy link
Owner

Hey there, a PR is welcome. I think it might be addListener for older browsers?

kostia1st pushed a commit to kostia1st/collapsed that referenced this issue Jul 17, 2023
kostia1st pushed a commit to kostia1st/collapsed that referenced this issue Jul 18, 2023
@kostia1st
Copy link
Contributor Author

I'm very sorry, I hurried up and made a mistake.
Please consider the newer PR

kostia1st pushed a commit to kostia1st/collapsed that referenced this issue Jul 18, 2023
kostia1st pushed a commit to kostia1st/collapsed that referenced this issue Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants