Skip to content
Open
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
1 change: 1 addition & 0 deletions src/TabBarTabsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class TabBarTabsNode extends React.Component {
key={key}
style={ style }
{...ref}
{...(typeof child.props.tab === 'string' ? {'data-tab': child.props.tab}: {})}
>
{child.props.tab}
</div>
Expand Down
3 changes: 3 additions & 0 deletions tests/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="false"
class=" rc-tabs-tab"
data-tab="tab 1"
role="tab"
>
tab 1
Expand All @@ -50,6 +51,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="true"
class="rc-tabs-tab-active rc-tabs-tab"
data-tab="tab 2"
role="tab"
>
tab 2
Expand All @@ -58,6 +60,7 @@ exports[`rc-tabs should render Tabs with correct DOM structure 1`] = `
aria-disabled="false"
aria-selected="false"
class=" rc-tabs-tab"
data-tab="tab 3"
role="tab"
>
tab 3
Expand Down
17 changes: 17 additions & 0 deletions tests/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,21 @@ describe('rc-tabs', () => {
done();
}, 1000);
});

it('string type tab should have [data-tab] attribute', () => {
const wrapper = mount(
<Tabs
defaultActiveKey="2"
renderTabBar={() => <ScrollableInkTabBar/>}
renderTabContent={() => <TabContent/>}
>
<TabPane tab="tab 1" key="1">first</TabPane>
<TabPane tab="tab 2" key="2">second</TabPane>
<TabPane tab="tab 3" key="3">third</TabPane>
<TabPane tab={<div>tab 4</div>} key="4">fourth</TabPane>
</Tabs>
);

expect(wrapper.find('[data-tab]').length).toBe(3);
})
});