[EuiProvider] Add a check and dev warning+early return for nested usage#6949
[EuiProvider] Add a check and dev warning+early return for nested usage#6949cee-chen merged 12 commits intoelastic:mainfrom
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/ |
clintandrewhall
left a comment
There was a problem hiding this comment.
This looks great, thank you so much. I'll try to test this against Kibana on Monday.
|
|
||
| export interface EuiProviderProps<T> | ||
| extends Omit<EuiThemeProviderProps<T>, 'children' | 'theme'>, | ||
| extends Pick<EuiThemeProviderProps<T>, 'colorMode' | 'modify'>, |
| export const getEuiDevProviderWarning = () => providerWarning; | ||
|
|
||
| // Not a public top-level EUI export, currently for internal use | ||
| export const emitEuiProviderWarning = (providerMessage: string) => { |
|
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
tkajtoch
left a comment
There was a problem hiding this comment.
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
EuiProviderinstantiated (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 nestingEuiProviderwhen they really wantEuiThemeProviderinstead.Things that occur with multiple nested
EuiProvider's that we want to avoid:<span>wrapper is rendered (due to the nestedEuiThemeProvder)componentDefaultscontext 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
@defaultif 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