question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useMediaQueries causing errors in production for some safari users

See original GitHub issue

If it’s a discussion, please start one here.

TypeError
a.addEventListener is not a function. (In 'a.addEventListener("change",e,!0)', 'a.addEventListener' is undefined)

Tracked down to: https://github.com/cultureamp/kaizen-design-system/blob/master/packages/responsive/src/useMediaQueries.tsx#L101

According to MediaQueryLists browser compatibility,

Before Safari 14, MediaQueryList is based on EventTarget, so you must use addListener() and removeListener() to observe media query lists.

  • Before opening this issue, I’ve searched open and closed issues for a fix.

Expected Behaviour

I’m not sure, either useMediaQueries should gracefully degrade (similar to how we check for Edge) or we should support older versions with addListener/removeListener.

Specifications (please add any other notable libs/details)

For performance-ui:

=> Found "@kaizen/responsive@1.2.1"
info Reasons this module exists
  - "@kaizen#brand-moment" depends on it
  - Hoisted from "@kaizen#brand-moment#@kaizen#responsive"
  - Hoisted from "@kaizen#draft-title-block-zen#@kaizen#responsive"

Not sure about others.

Labelling

  1. If related to a component, please add a label like so component:mycomponent.
  2. Then label with bug, enhancement/feature* or documentation.

* A feature is a new component or piece of functionality and an enhancement is an improvement to an existing component or piece of functionality.

No Sensitive Information

As this is a public repo, please do not include screenshots that may share sensitive information about our customers.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
OliBridgmancommented, Nov 28, 2021

@sentience 45 instances of the error in performance-ui for the past 2 weeks. Not sure how many users you can relate that to (and I don’t think you can with sentry set up the way it is atm) but if you trust the URL there’s at least 9 distinct companies over that time.

0reactions
dougmacknzcommented, Nov 28, 2021

Yeah, the downgraded experience is that it will not respond to window changes after page load, so it’s not too bad. There’s already some code in this component to do that for legacy Edge, so I’d just add legacy Safari to that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useMediaQuery not supported on iOS 13< #5467 - GitHub
"Support for matchMedia is only partial in Safari (Desktop and iOS) including Safari 13 (Technology Preview), because the MediaQueryList object ...
Read more >
Media query not working in React - Stack Overflow
I'm trying to hide an image when the screen/viewport has a width over 900px. For some reason ...
Read more >
Media Queries Level 4 - W3C
A media query is a method of testing certain aspects of the user agent ... where negative values on these properties caused a...
Read more >
What does this actually indicate? CoreMediaErrorDomain ...
During the course of stream a live HTTP Video Stream intermittently these errors show up in the logs for AVPlayer. What problem are...
Read more >
Media Queries for Standard Devices - CSS-Tricks
We have recently launched a new website that uses responsive design. However we are hearing from some users that the site is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found