Skip to content

[EuiTabs] Child EuiTabs in nested wrappers do not correctly inherit size from EuiTabs #6367

@cee-chen

Description

@cee-chen

As of the EuiTabs Emotion conversion (#6311), child EuiTab now need to be passed size and expand.

const tabItems = React.Children.map(children, (child) => {
if (React.isValidElement(child)) {
return cloneElementWithCss(child, {
// we're passing the parent `size` and `expand` down to the children
size: size,
expand: expand,
});
}
});

However, the above code only captures EuiTab children that are direct descendants of EuiTabs. It does not correctly pass down size to grandchild, anywhere within the EuiTabs parent, e.g.

<EuiTabs size="l">
  <SomeIntermediateWrapper>
    <EuiTab> // will be size "m" / will not inherit size "l"

Link to actual production example in Kibana where consumers have a perfectly acceptable use case of a React component wrapper that handles click behavior.

The more robust architecture/approach we should be using is using a React context provider to pass size and expand to all children, following EuiDescriptionList's example:

<EuiDescriptionListContext.Provider
value={{ type, compressed, textStyle, align, gutterSize }}
>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions