-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiProvider] Add a check and dev warning+early return for nested usage #6949
Conversation
- they don't really belong in `EuiProvider`
- make `EuiProvider`s tests more basic in comparison - use `toHaveStyleRule` instead of snapshots
- clarify in as many places as possible - remove uncertain language (e.g. 'currently', 'future') that were still not yet figured out when docs were written - try to remove overlap in docs between provider and theme provider, try to clarify nested usage of theme provider - add examples to warning section
@clintandrewhall feel free to skip reviewing the commits that are labelled |
@clintandrewhall I'd also love feedback on the updated docs for EuiProvider and EuiThemeProvider (once staging is done spinning up). I totally agree the language was really not clear around their usage and it's hopefully much better now. Please feel free to leave any suggestions if you think any of the copy there could be improved! |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6949/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6949/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you so much. I'll try to test this against Kibana on Monday.
|
||
const isEmotionCacheObject = ( | ||
obj: EmotionCache | Object | ||
): obj is EmotionCache => obj.hasOwnProperty('key'); | ||
|
||
export interface EuiProviderProps<T> | ||
extends Omit<EuiThemeProviderProps<T>, 'children' | 'theme'>, | ||
extends Pick<EuiThemeProviderProps<T>, 'colorMode' | 'modify'>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
@@ -14,3 +14,20 @@ export const setEuiDevProviderWarning = (level: LEVELS | undefined) => | |||
(providerWarning = level); | |||
|
|||
export const getEuiDevProviderWarning = () => providerWarning; | |||
|
|||
// Not a public top-level EUI export, currently for internal use | |||
export const emitEuiProviderWarning = (providerMessage: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
Do you want anyone from @elastic/eui-team to review this before committing? It looks great to me, and I can test it in Kibana on Monday. |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6949/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6949/ |
c849b9b
to
e03d477
Compare
e03d477
to
0fadabd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look great! Feel free to merge as soon as CI passes :)
Preview documentation changes for this PR: https://eui.elastic.co/pr_6949/ |
## Summary `eui@84.0.0` ⏩ `eui@85.0.1` ## [`85.0.1`](https://github.com/elastic/eui/tree/v85.0.1) **Bug fixes** - Fixed `EuiFilterGroup`'s responsive styles ([#6983](elastic/eui#6983)) ## [`85.0.0`](https://github.com/elastic/eui/tree/v85.0.0) - Updated `EuiThemeProvider` to set an Emotion theme context that returns the values of `useEuiTheme()` ([#6913](elastic/eui#6913)) - Added `size` prop to `EuiStepsHorizontal`, defaulting to the previous size of `m` ([#6928](elastic/eui#6928)) - Added new `s` sizing to `EuiStepsHorizontal` ([#6928](elastic/eui#6928)) - Added `at` and `key` icon glyphs. ([#6934](elastic/eui#6934)) - Added a new `cloneElementWithCss` Emotion utility ([#6939](elastic/eui#6939)) - Updated `EuiPopover` to allow consumer control of all `focusTrapProps` ([#6955](elastic/eui#6955)) **Bug fixes** - Fixed `EuiDataGrid` height calculation bug when browser zoom levels are not 100% ([#6895](elastic/eui#6895)) - Fixed `EuiTab` not correctly passing selection color state to `prepend` and `append` children ([#6938](elastic/eui#6938)) - Fixed `EuiInputPopover` to allow consumer control of its focus trap via `focusTrapProps` ([#6955](elastic/eui#6955)) **Breaking changes** - `EuiProvider` will no longer render multiple or duplicate nested instances of itself. If a nested `EuiProvider` is detected, that instance will return early without further processing, and will warn if configured to do so via `setEuiDevProviderWarning`. For nested theming, use `EuiThemeProvider` instead. ([#6949](elastic/eui#6949)) - Removed `onTrapDeactivation` prop from `EuiPopover`. Use `focusTrapProps.onDeactivation` instead ([#6955](elastic/eui#6955)) **CSS-in-JS conversions** - Converted `EuiFilterGroup` and `EuiFilterButton` to Emotion; Removed styles attached to `.euiFilterGroup__popoverPanel` ([#6957](elastic/eui#6957)) --------- Co-authored-by: Cee Chen <constance.chen@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary `eui@84.0.0` ⏩ `eui@85.0.1` ## [`85.0.1`](https://github.com/elastic/eui/tree/v85.0.1) **Bug fixes** - Fixed `EuiFilterGroup`'s responsive styles ([elastic#6983](elastic/eui#6983)) ## [`85.0.0`](https://github.com/elastic/eui/tree/v85.0.0) - Updated `EuiThemeProvider` to set an Emotion theme context that returns the values of `useEuiTheme()` ([elastic#6913](elastic/eui#6913)) - Added `size` prop to `EuiStepsHorizontal`, defaulting to the previous size of `m` ([elastic#6928](elastic/eui#6928)) - Added new `s` sizing to `EuiStepsHorizontal` ([elastic#6928](elastic/eui#6928)) - Added `at` and `key` icon glyphs. ([elastic#6934](elastic/eui#6934)) - Added a new `cloneElementWithCss` Emotion utility ([elastic#6939](elastic/eui#6939)) - Updated `EuiPopover` to allow consumer control of all `focusTrapProps` ([elastic#6955](elastic/eui#6955)) **Bug fixes** - Fixed `EuiDataGrid` height calculation bug when browser zoom levels are not 100% ([elastic#6895](elastic/eui#6895)) - Fixed `EuiTab` not correctly passing selection color state to `prepend` and `append` children ([elastic#6938](elastic/eui#6938)) - Fixed `EuiInputPopover` to allow consumer control of its focus trap via `focusTrapProps` ([elastic#6955](elastic/eui#6955)) **Breaking changes** - `EuiProvider` will no longer render multiple or duplicate nested instances of itself. If a nested `EuiProvider` is detected, that instance will return early without further processing, and will warn if configured to do so via `setEuiDevProviderWarning`. For nested theming, use `EuiThemeProvider` instead. ([elastic#6949](elastic/eui#6949)) - Removed `onTrapDeactivation` prop from `EuiPopover`. Use `focusTrapProps.onDeactivation` instead ([elastic#6955](elastic/eui#6955)) **CSS-in-JS conversions** - Converted `EuiFilterGroup` and `EuiFilterButton` to Emotion; Removed styles attached to `.euiFilterGroup__popoverPanel` ([elastic#6957](elastic/eui#6957)) --------- Co-authored-by: Cee Chen <constance.chen@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
@clintandrewhall is working on ensuring all Kibana plugins have
EuiProvider
instantiated (in order for color mode to work correctly across Kibana). Unfortunately, due to the complexity of Kibana and its multiple teams, there are several instances of teams using or nestingEuiProvider
when they really wantEuiThemeProvider
instead.Things that occur with multiple nested
EuiProvider
's that we want to avoid:<span>
wrapper is rendered (due to the nestedEuiThemeProvder
)componentDefaults
context will be overridden, potentially unintentionallyIn light of these side effects, and to help facilitate Shared UX's work, we're 1. baking into EuiProvider a lack of ability to nest multiple usages, and 2. warning if the above happens, and 3. clarifying our docs to hopefully make the relationship between
<EuiProvider>
and<EuiThemeProvider>
clearer.QA
General checklist
@default
if default values are missing)and playground togglesand cypress tests- [ ] Checked in mobile- [ ] Checked in Chrome, Safari, Edge, and Firefox- [ ] Checked for accessibility including keyboard-only and screenreader modes- [ ] Updated the Figma library counterpart