From 2558f32b92166c6b0dddda38c4d344fcf4356e74 Mon Sep 17 00:00:00 2001 From: AlexKVal Date: Fri, 24 Jul 2015 23:08:16 +0300 Subject: [PATCH] [fixed] TabbedArea panes rendering with animation --- src/TabbedArea.js | 49 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/TabbedArea.js b/src/TabbedArea.js index 9a1c1ae3b9..89021be333 100644 --- a/src/TabbedArea.js +++ b/src/TabbedArea.js @@ -51,8 +51,22 @@ const TabbedArea = React.createClass({ componentWillReceiveProps(nextProps) { if (nextProps.activeKey != null && nextProps.activeKey !== this.props.activeKey) { + // check if the 'previousActiveKey' child still exists + let previousActiveKey = this.props.activeKey; + React.Children.forEach(nextProps.children, (child) => { + if (React.isValidElement(child)) { + if (child.props.eventKey === previousActiveKey) { + this.setState({ + previousActiveKey + }); + return; + } + } + }); + + // if the 'previousActiveKey' child does not exist anymore this.setState({ - previousActiveKey: this.props.activeKey + previousActiveKey: null }); } }, @@ -66,15 +80,12 @@ const TabbedArea = React.createClass({ render() { let { id, ...props } = this.props; - let activeKey = - this.props.activeKey != null ? this.props.activeKey : this.state.activeKey; - function renderTabIfSet(child) { return child.props.tab != null ? this.renderTab(child) : null; } let nav = ( -