Browse Source

improve tabs demo (#14701)

pull/14719/head
gyh9457 6 years ago
committed by zombieJ
parent
commit
c895c809f9
  1. 8
      components/tabs/demo/custom-add-trigger.md
  2. 8
      components/tabs/demo/editable-card.md

8
components/tabs/demo/custom-add-trigger.md

@ -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 });
}

8
components/tabs/demo/editable-card.md

@ -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…
Cancel
Save