Skip to content

Commit 0255921

Browse files
committed
Add controlled mode for tabs
1 parent ac1c1f8 commit 0255921

File tree

9 files changed

+518
-421
lines changed

9 files changed

+518
-421
lines changed

src/components/Tab.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export default class Tab extends Component {
2323
]),
2424
className: PropTypes.string,
2525
disabled: PropTypes.bool,
26-
focus: PropTypes.bool,
27-
id: PropTypes.string,
28-
panelId: PropTypes.string,
29-
selected: PropTypes.bool,
30-
tabRef: PropTypes.func,
26+
focus: PropTypes.bool, // private
27+
id: PropTypes.string, // private
28+
panelId: PropTypes.string, // private
29+
selected: PropTypes.bool, // private
30+
tabRef: PropTypes.func, // private
3131
};
3232

3333
componentDidMount() {

src/components/TabPanel.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,25 @@ import cx from 'classnames';
44

55
export default class TabPanel extends Component {
66

7-
static contextTypes = {
8-
forceRenderTabPanel: PropTypes.bool,
9-
};
10-
117
static defaultProps = {
12-
id: null,
13-
selected: false,
14-
tabId: null,
8+
style: {},
159
};
1610

1711
static propTypes = {
1812
children: PropTypes.node,
1913
className: PropTypes.string,
20-
id: PropTypes.string,
21-
selected: PropTypes.bool,
14+
forceRenderTabPanel: PropTypes.bool, // private
15+
id: PropTypes.string, // private
16+
selected: PropTypes.bool, // private
2217
style: PropTypes.object,
23-
tabId: PropTypes.string,
18+
tabId: PropTypes.string, // private
2419
};
2520

2621
render() {
2722
const {
2823
children,
2924
className,
25+
forceRenderTabPanel,
3026
id,
3127
selected,
3228
style,
@@ -48,7 +44,7 @@ export default class TabPanel extends Component {
4844
aria-labelledby={tabId}
4945
style={{ ...style, display: selected ? null : 'none' }}
5046
>
51-
{(this.context.forceRenderTabPanel || selected) ? children : null}
47+
{(forceRenderTabPanel || selected) ? children : null}
5248
</div>
5349
);
5450
}

0 commit comments

Comments
 (0)