Fix some style and react key problems

This commit is contained in:
afc163 2015-12-15 11:38:27 +08:00
parent 349d03e384
commit b115f000f9
3 changed files with 12 additions and 8 deletions

View File

@ -20,9 +20,9 @@ function newTabPane() {
ReactDOM.render(
<Tabs onChange={callback} type="card" editable newTabPane={newTabPane}>
<TabPane tab="" key="1">选项卡一内容</TabPane>
<TabPane tab="" key="2">选项卡二内容</TabPane>
<TabPane tab="" key="3">选项卡三内容</TabPane>
<TabPane tab="选项卡" key="1">选项卡一内容</TabPane>
<TabPane tab="选项卡" key="2">选项卡二内容</TabPane>
<TabPane tab="选项卡" key="3">选项卡三内容</TabPane>
</Tabs>
, document.getElementById('components-tabs-demo-new-and-close'));
````

View File

@ -53,7 +53,9 @@ class AntTabs extends React.Component {
}
});
if (activeKey === key) {
activeKey = tabs[foundIndex - 1].key;
foundIndex = foundIndex - 1;
foundIndex = foundIndex >= 0 ? foundIndex : 0;
activeKey = tabs[foundIndex].key;
}
this.setState({
tabs,
@ -94,10 +96,10 @@ class AntTabs extends React.Component {
children = this.state.tabs;
}
// Add new tab handler
tabBarExtraContent = [
<Icon type="plus" className={prefixCls + '-new-tab'} onClick={this.createNewTab} />,
tabBarExtraContent,
];
tabBarExtraContent = <span>
<Icon type="plus" className={prefixCls + '-new-tab'} onClick={this.createNewTab} />
{tabBarExtraContent}
</span>;
}
// Wrap the extra content
tabBarExtraContent = <div className={prefixCls + '-extra-content'}>

View File

@ -397,6 +397,7 @@
margin-right: 0;
margin-left: 4px;
font-size: 12px;
width: 12px;
color: #999;
transition: color 0.3s ease;
&:hover {
@ -417,6 +418,7 @@
border-radius: 3px;
border: 1px solid @border-color-base;
font-size: 12px;
.iconfont-size-under-12px(10px);
transition: color 0.3s ease;
&:hover {
color: @primary-color;