From f7103ee961d3e8d43b600e9a8bcdb0c9c696e852 Mon Sep 17 00:00:00 2001 From: Tobias Date: Sat, 2 Feb 2019 22:27:07 +0100 Subject: [PATCH] fix: make #tabs work with React define content config --- packages/dnb-ui-lib/src/components/tabs/Tabs.js | 15 +++++++-------- .../__tests__/__snapshots__/Tabs.test.js.snap | 7 ++++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/dnb-ui-lib/src/components/tabs/Tabs.js b/packages/dnb-ui-lib/src/components/tabs/Tabs.js index a83ecc2dc09..19c7779bb94 100644 --- a/packages/dnb-ui-lib/src/components/tabs/Tabs.js +++ b/packages/dnb-ui-lib/src/components/tabs/Tabs.js @@ -114,9 +114,8 @@ export default class Tabs extends PureComponent { ) { res = props.children.reduce((acc, content, i) => { if ( - content.type && - (content.type.name || content.type.displayName) === - 'CustomContent' + content.props && + content.props.displayName === 'CustomContent' // we use this sollution, as Component.displayName ) { // tabs data from main prop const dataProps = @@ -292,7 +291,7 @@ export default class Tabs extends PureComponent { } renderActiveTab(tabKey) { - return `dnb-tablink dnb-no-mouse-focus tab--${tabKey} ${ + return `dnb-tablink tab--${tabKey} ${ this.isSelected(tabKey) ? 'selected' : '' }` } @@ -489,10 +488,7 @@ class ContentWrapper extends PureComponent { } render() { const { id, children } = this.props - const key = - this.props.selected_key || - (this._reactInternalFiber && this._reactInternalFiber.key) || - 'key' + const key = this.props.selected_key || 'key' return (
*/ class CustomContent extends PureComponent { + static name2 = 'CustomContent' static propTypes = { + displayName: PropTypes.string, // eslint-disable-line title: PropTypes.string, // eslint-disable-line hash: PropTypes.string, // eslint-disable-line selected: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), // eslint-disable-line @@ -524,6 +522,7 @@ class CustomContent extends PureComponent { children: PropTypes.node.isRequired } static defaultProps = { + displayName: 'CustomContent', title: null, hash: null, selected: null, diff --git a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/Tabs.test.js.snap b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/Tabs.test.js.snap index 1418584c141..a31c50e7c0f 100644 --- a/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/Tabs.test.js.snap +++ b/packages/dnb-ui-lib/src/components/tabs/__tests__/__snapshots__/Tabs.test.js.snap @@ -35,6 +35,7 @@ exports[`Tabs component have to match snapshot 1`] = ` "props": Object { "children": "children", "disabled": "disabled", + "displayName": "displayName", "hash": "hash", "selected": "selected", "title": "title", @@ -92,7 +93,7 @@ exports[`Tabs component have to match snapshot 1`] = ` >