diff --git a/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx b/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx index aaa7ba406d..3c68ffa619 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Tabs.jsx @@ -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',