mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
improve tabs demo (#14701)
This commit is contained in:
parent
0d65f0578d
commit
c895c809f9
@ -55,8 +55,12 @@ class Demo extends React.Component {
|
||||
}
|
||||
});
|
||||
const panes = this.state.panes.filter(pane => pane.key !== targetKey);
|
||||
if (lastIndex >= 0 && activeKey === targetKey) {
|
||||
activeKey = panes[lastIndex].key;
|
||||
if (panes.length && activeKey === targetKey) {
|
||||
if (lastIndex >= 0) {
|
||||
activeKey = panes[lastIndex].key;
|
||||
} else {
|
||||
activeKey = panes[0].key;
|
||||
}
|
||||
}
|
||||
this.setState({ panes, activeKey });
|
||||
}
|
||||
|
@ -61,8 +61,12 @@ class Demo extends React.Component {
|
||||
}
|
||||
});
|
||||
const panes = this.state.panes.filter(pane => pane.key !== targetKey);
|
||||
if (lastIndex >= 0 && activeKey === targetKey) {
|
||||
activeKey = panes[lastIndex].key;
|
||||
if (panes.length && activeKey === targetKey) {
|
||||
if (lastIndex >= 0) {
|
||||
activeKey = panes[lastIndex].key;
|
||||
} else {
|
||||
activeKey = panes[0].key;
|
||||
}
|
||||
}
|
||||
this.setState({ panes, activeKey });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user