fix(dashboard): fix nested tab (#15134)

This commit is contained in:
Yaozong Liu 2021-06-17 13:31:52 +08:00 committed by GitHub
parent cb10427b1e
commit e5187a479a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -156,7 +156,11 @@ class Tabs extends React.PureComponent {
const lastTabId = nextTabsIds[nextTabsIds.length - 1];
// if a new tab is added focus on it immediately
if (nextTabsIds.length > currTabsIds.length) {
this.setState(() => ({ activeKey: lastTabId }));
// a new tab's path may be empty, here also need to set tabIndex
this.setState(() => ({
activeKey: lastTabId,
tabIndex: maxIndex,
}));
}
// if a tab is removed focus on the first
if (nextTabsIds.length < currTabsIds.length) {
@ -200,7 +204,7 @@ class Tabs extends React.PureComponent {
onOk: () => {
deleteComponent(key, component.id);
const tabIndex = component.children.indexOf(key);
this.handleClickTab(Math.max(0, tabIndex - 1));
this.handleDeleteTab(tabIndex);
},
okType: 'danger',
okText: 'DELETE',