Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions components/molecule/tabs/src/components/MoleculeTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const MoleculeTabs = ({
type = TYPES.HORIZONTAL,
variant = VARIANTS.CLASSIC,
tabsJustifyContent = TABS_JUSTIFY_CONTENT.FLEX_START,
keepTabsContentMounted = false
keepTabsContentMounted = false,
...props
}) => {
const className = cx(BASE_CLASS, {
[`${BASE_CLASS}--${variant}`]: variant,
Expand Down Expand Up @@ -136,15 +137,22 @@ const MoleculeTabs = ({
numTab,
id,
onChange,
ref: el => (tabRefs.current[index] = el) // Assign ref to each MoleculeTab
ref: el => (tabRefs.current[index] = el), // Assign ref to each MoleculeTab
key: index
})
})

const tabContent = childrenArray.reduce((activeContent, child) => {
const tabContent = childrenArray.reduce((activeContent, child, currentIndex) => {
if (child) {
const {children: childrenChild, active, numTab} = child.props
activeContent.push(
<Wrapper id={id} keepTabsContentMounted={keepTabsContentMounted} isActive={active} numTab={numTab}>
<Wrapper
id={id}
keepTabsContentMounted={keepTabsContentMounted}
isActive={active}
numTab={numTab}
key={currentIndex}
>
{childrenChild}
</Wrapper>
)
Expand All @@ -153,7 +161,7 @@ const MoleculeTabs = ({
}, [])

return (
<div className={className}>
<div className={className} {...props}>
<ul
ref={outerRef}
className={CLASS_SCROLLER}
Expand Down
4 changes: 2 additions & 2 deletions components/molecule/tabs/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe(json.name, () => {
expect(container.innerHTML).to.not.have.lengthOf(0)
})

it('should NOT extend classNames', () => {
it('should extend classNames', () => {
// Given
const props = {
className: 'extended-classNames'
Expand All @@ -90,7 +90,7 @@ describe(json.name, () => {
const findClassName = findSentence(props.className)

// Then
expect(findClassName(container.innerHTML)).to.be.null
expect(findClassName(container.innerHTML)).to.not.be.null
})

it('should display the active content', () => {
Expand Down
Loading