From e5187a479afa0ed8dea53b14f35c7189a3fdb4d8 Mon Sep 17 00:00:00 2001 From: Yaozong Liu <750188453@qq.com> Date: Thu, 17 Jun 2021 13:31:52 +0800 Subject: [PATCH] fix(dashboard): fix nested tab (#15134) --- .../src/dashboard/components/gridComponents/Tabs.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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',