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

Only add a media query event listener where supported #1387

Merged
merged 7 commits into from
Aug 25, 2021

Conversation

jfuchs
Copy link
Contributor

@jfuchs jfuchs commented Aug 23, 2021

This change fixes an issue in safari 13 where an unhandled error from ThemeProvider would cause blank pages. This approach has limitations:

  • In Safari 13 we aren't updating the system color mode
  • This PR doesn't attempt to fix error handling or lint for calls to APIs unsupported in Safari 13

Closes #1366

Screenshots

Please provide before/after screenshots for any visual changes

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@jfuchs jfuchs requested a review from colebemis August 23, 2021 18:03
@changeset-bot
Copy link

changeset-bot bot commented Aug 23, 2021

🦋 Changeset detected

Latest commit: bb2911d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 23, 2021

size-limit report 📦

Path Size
dist/browser.esm.js 48.34 KB (0%)
dist/browser.umd.js 48.62 KB (0%)

@@ -108,11 +108,11 @@ function useSystemColorMode() {
}

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
media?.addEventListener('change', handleChange)
media?.addEventListener?.('change', handleChange)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use .addListener() when .addEventListener() is not supported?

@colebemis
Copy link
Contributor

Looks good! If you confirmed that this fixes the bug in Safari 13, go ahead and merge it 👍

@colebemis colebemis merged commit 6b4d52d into main Aug 25, 2021
@colebemis colebemis deleted the addEventListener-safari-13 branch August 25, 2021 19:50
@primer-css primer-css mentioned this pull request Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blank page on Safari 13 when using useTheme
2 participants