Skip to content

Commit

Permalink
Optional matchMedia calls
Browse files Browse the repository at this point in the history
  • Loading branch information
gethinwebster committed Jun 12, 2023
1 parent c9faa9e commit fd3e524
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/code-editor/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getDefaultTheme(element: HTMLElement): CodeEditorProps.Theme {
!!findUpUntil(
element,
node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode')
) && !window?.matchMedia('print').matches;
) && !window?.matchMedia?.('print').matches;
return isDarkMode ? DEFAULT_DARK_THEME : DEFAULT_LIGHT_THEME;
}

Expand Down
2 changes: 1 addition & 1 deletion src/internal/hooks/use-visual-mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useCurrentMode(elementRef: React.RefObject<HTMLElement>) {
findUpUntil(
node,
node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode')
) && !window?.matchMedia('print').matches;
) && !window?.matchMedia?.('print').matches;
setValue(darkModeParent ? 'dark' : 'light');
});
return value;
Expand Down

0 comments on commit fd3e524

Please sign in to comment.