Skip to content

Commit

Permalink
Add workaround for font-optical-sizing issue in Safari 16 (#11503)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronccasanova authored Jan 26, 2024
1 parent a6ac992 commit fb7d968
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-colts-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Added workaround for `font-optical-sizing` issue in Safari 16
6 changes: 6 additions & 0 deletions polaris-react/src/components/AppProvider/AppProvider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ button::-moz-focus-inner,
[type='submit']::-moz-focus-inner {
border-style: none;
}

// stylelint-disable-next-line selector-no-qualifying-type -- Workaround for `font-optical-sizing` issue in Safari 16 (Adapted from https://clagnut.com/blog/2423)
html[class~='Polaris-Safari-16-Font-Optical-Sizing-Patch'] {
// Inter's "opsz" axis ranges from 14 to 32. This patch optimizes for smaller and less legible text by setting "opsz" 14 for all font sizes.
font-variation-settings: 'opsz' 14;
}
13 changes: 13 additions & 0 deletions polaris-react/src/components/AppProvider/AppProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ export class AppProvider extends Component<AppProviderProps, State> {
this.stickyManager.setContainer(document);
this.setBodyStyles();
this.setRootAttributes();

const isSafari16 =
navigator.userAgent.includes('Safari') &&
!navigator.userAgent.includes('Chrome') &&
(navigator.userAgent.includes('Version/16.1') ||
navigator.userAgent.includes('Version/16.2') ||
navigator.userAgent.includes('Version/16.3'));

if (isSafari16) {
document.documentElement.classList.add(
'Polaris-Safari-16-Font-Optical-Sizing-Patch',
);
}
}
measureScrollbars();
}
Expand Down

0 comments on commit fb7d968

Please sign in to comment.