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

[EuiGlobalStyles] Omit global and reset styles when using legacy theme #5473

Merged
merged 4 commits into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed `EUiDataGrid`'s cell popover overlapping with modals and flyouts ([#5461](https://github.com/elastic/eui/pull/5461))
- Fixed an accessibility issue where `EuiDatePicker` time options did not have unique IDs ([#5466](https://github.com/elastic/eui/pull/5466))
- Removed CSS-in-JS global and reset styles from `EuiProvider` when using the legacy theme ([#5473](https://github.com/elastic/eui/pull/5473))

## [`43.1.0`](https://github.com/elastic/eui/tree/v43.1.0)

Expand Down
4 changes: 1 addition & 3 deletions src/components/provider/__snapshots__/provider.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,7 @@ exports[`EuiProvider changing themes propagates \`theme\` 1`] = `
},
}
}
>
<EuiGlobalStyles />
</EuiThemeProvider>
/>
`;

exports[`EuiProvider is rendered 1`] = `
Expand Down
21 changes: 11 additions & 10 deletions src/components/provider/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiThemeProviderProps,
EuiThemeSystem,
} from '../../services';
import { EuiThemeAmsterdam } from '../../themes/amsterdam/theme';
import { EuiThemeAmsterdam, isLegacyTheme } from '../../themes';

export interface EuiProviderProps<T>
extends Omit<EuiThemeProviderProps<T>, 'children' | 'theme'>,
Expand All @@ -38,18 +38,19 @@ export const EuiProvider = <T extends {} = {}>({
modify,
children,
}: PropsWithChildren<EuiProviderProps<T>>) => {
return theme !== null ? (
return theme === null ? (
<EuiThemeProvider colorMode={colorMode}>{children}</EuiThemeProvider>
) : (
<EuiThemeProvider theme={theme} colorMode={colorMode} modify={modify}>
{cache ? (
<CacheProvider value={cache}>
{!isLegacyTheme(theme.key) &&
(cache ? (
<CacheProvider value={cache}>
<EuiGlobalStyles />
</CacheProvider>
) : (
<EuiGlobalStyles />
</CacheProvider>
) : (
<EuiGlobalStyles />
)}
))}
{children}
</EuiThemeProvider>
) : (
<EuiThemeProvider colorMode={colorMode}>{children}</EuiThemeProvider>
);
};