Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Emotion] Fix consumer css overriding (instead of merging with) EUI c…
…ss in child props (#6896) * [setup] Document `shouldRenderCustomStyles` options type more cleanly - since I'll be adding a few more needed options here shortly * [setup] Move `assertOutputStyles` to internal util - will be adding a few more here shortly, as well as extending the fn, and it's nice not to have to continously pass `options` around * [setup] DRY out render + renderCallback to a util - will be adding another util here shortly that will be using it, and 3 times is enough to DRY it out * [setup] DRY out `childProps` merge util - the next util we're adding will use it * [FIX] Ensure that `css` props do not override baseline EUI `css` - this is the main fix/guard/detection for the buggy behavior found in this PR - it acts by rendering the baseline component w/ no custom `css`, grabbing the Emotion className generated, and ensuring the custom `css` is appended to the end of it instead of gobbling it - this behavior primarily affects nested `childProps` components, as Emotion does not auto-merge `css` props that isn't the immediately returned element / isn't at the top level of the component * [FIX] Fix `shouldRenderCustomStyles` not merging css no matter what - Emotion handles merging automatically, so this essentially mimics end behavior but in test * [EuiAccordion] Fix `buttonProps.css` and `arrowProps.css` overriding EUI css * [EuiBadge] Fix `closeButtonProps.css` overriding EUI css * [EuiCard] Fix `betaBadgeProps.css` and `betaBadgeProps.anchorProps.css` overriding EUI css * [EuiExpression] Fix `descriptionProps` and `valueProps` overrides - fix childProps `className` not being correctly merged - fix `css` not being correctly merged - rewrite `style` merge/overrides a bit more succinctly * [EuiFlyout] Fix `closeButtonProps.css` overriding EUI css * [EuiKeyPadMenu] Fix `checkable.legendProps.css` overriding EUI css + DRY out checkable typeof logic * [EuiListGroupItem] Fix `iconProps.css` overriding EUI css * [EuiPageBody] Fix `panelProps.css` overriding EUI css - extracting `css` out and setting it to the end of the array ensures it will always correctly come after EUI styles + misc cleanup / better organization of code + add extra non-panelled test * [EuiPageHeaderContent] Fix `iconProps.css` overriding EUI css * [EuiProgress] Fix `labelProps.css` overriding EUI css * [EuiTour] Fix `panelProps` test - behavior is working, but because EuiTour has conflates some props with `panelProps`, we need to isolate and not pass any extra `css` (in `requiredProps`) other than what is automatically tested * [enhancement] Add `options.wrapper` API to `shouldRenderCustomStyles` + update `EuiResizablePanel` to use this new `wrapper` options, which both significantly DRYs out behavior as well as allowing `shouldRenderCustomStyles` to clone props correctly * [EuiResizablePanel] Fix `wrapperProps.css` overriding EUI css * [EuiIcon] Fix failing svg test - bogart the new wrapper API to preload `appendIconComponentCache`, otherwise the EUI class comparisons encounter race conditions with the `isLoading` CSS * [EuiImage] Fix `wrapperProps.css` overriding EUI css * [EuiImage] Fix fullscreen wrapper css + add `targetSelector` API to `shouldRenderCustomStyles` - EuiImage renders multiple copies of an image wrapper on the page, so we need a specific way of targeting which DOM node to get the right Emotion classes from + convert remaining tests to RTL as cleanup/tech debt + remove skipped test entirely * [opinionated] Remove custom `css_before_spread_props` lint rule - As noted, Emotion does not auto-merge non-top-level props so we need to do it manually for css merging to work correctly. This means a lot of disables - we're probably better off linting for the presence of `shouldRenderCustomStyles` instead, which actually tests for working Emotion CSS * [docs] Add wiki documentation of this behavior * changelog
- Loading branch information