You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[EuiTabs] Child EuiTabs in nested wrappers do not correctly inherit size from EuiTabs #6367
// 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"
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:
changed the title [-][EuiTabs] Child `EuiTab` in nested wrappers do not correctly inherit `size` from `EuiTabs`[/-][+][EuiTabs] Child `EuiTab`s in nested wrappers do not correctly inherit `size` from `EuiTabs`[/+]on Nov 15, 2022
For backward compatibility and to be able to customize individual tabs separately, EuiTab component would have size and expand both from its own props and from EuiTabsContext right?
And use values from context only ifsize or expand props of EuiTab are undefined (not passed by user ), then add styles from Emotion like (expand ?? parentExpand) && tabStyles.expanded,. In other words, prop values will take precedence over context values.
Hmmm - so, on principle I agree with you, but for consistency I think we'd want to handle this the same way we handle children in EuiDescriptionList. It looks like we do not inherit props directly, and instead now fully rely on context:
I think this is valid honestly because no one should really be using EuiTab outside of EuiTabs (and mostly people use EuiTabs with the tabs API in any case as opposed to individual children).
My vote would be to mark the removal of size and expand on EuiTab as a breaking change, and inherit only from the context. TBH, for those specific props it makes sense as well from a design/UI perspective - we don't really want consumers creating tab groups of varying sizes and expansion levels.
I thought that way in order to not break any existing functionality by doing so. If we are going to mark it as breaking change, I agree with everything you said. Thanks for your detailed explanation!
Activity
cee-chen commentedon Nov 15, 2022
@breehall would you be interested in picking this up some point, since you already have props/context experience from
EuiDescriptionList? 🙏[-][EuiTabs] Child `EuiTab` in nested wrappers do not correctly inherit `size` from `EuiTabs`[/-][+][EuiTabs] Child `EuiTab`s in nested wrappers do not correctly inherit `size` from `EuiTabs`[/+]dawitamene commentedon Dec 2, 2022
@constancecchen, If maybe @breehall is busy, can I work on this?
cee-chen commentedon Dec 2, 2022
@dawitam11 Absolutely!
dawitamene commentedon Dec 8, 2022
@constancecchen
For backward compatibility and to be able to customize individual tabs separately,
EuiTabcomponent would havesizeandexpandboth from its own props and fromEuiTabsContextright?export const EuiTab: FunctionComponent = ({ isSelected, children, className, disabled: _disabled, href, target, rel, prepend, append, size, expand, ...rest }) => { const { size: parentSize, expand: parentExpand } = useContext(EuiTabsContext) const euiTheme = useEuiTheme(); const isHrefValid = !href || validateHref(href); const disabled = _disabled || !isHrefValid;And use values from context only if
sizeorexpandprops ofEuiTabare undefined (not passed by user ), then add styles from Emotion like(expand ?? parentExpand) && tabStyles.expanded,. In other words, prop values will take precedence over context values.cee-chen commentedon Dec 8, 2022
Hmmm - so, on principle I agree with you, but for consistency I think we'd want to handle this the same way we handle children in
EuiDescriptionList. It looks like we do not inherit props directly, and instead now fully rely on context:eui/src/components/description_list/description_list_title.tsx
Lines 21 to 28 in 6018d7e
I think this is valid honestly because no one should really be using
EuiTaboutside ofEuiTabs(and mostly people useEuiTabswith thetabsAPI in any case as opposed to individual children).My vote would be to mark the removal of
sizeandexpandonEuiTabas a breaking change, and inherit only from the context. TBH, for those specific props it makes sense as well from a design/UI perspective - we don't really want consumers creating tab groups of varying sizes and expansion levels.Hope that makes sense!
dawitamene commentedon Dec 13, 2022
@constancecchen
I thought that way in order to not break any existing functionality by doing so. If we are going to mark it as breaking change, I agree with everything you said. Thanks for your detailed explanation!