Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(editor): correct 'Close to the Right' behavior when invoked on inactive tab (#40709)

Marouane Soudae1f758ad40c7
diff --git a/apps/studio/components/layouts/Tabs/Tabs.tsx b/apps/studio/components/layouts/Tabs/Tabs.tsx
index 0816bd0a3f9..02744f6c4e5 100644
--- a/apps/studio/components/layouts/Tabs/Tabs.tsx
+++ b/apps/studio/components/layouts/Tabs/Tabs.tsx
@@ -116,8 +116,15 @@ export const EditorTabs = () => {
? tabs.openTabs.filter((x) => !x.startsWith('sql'))
: tabs.openTabs.filter((x) => x.startsWith('sql'))
const tabIdx = openedTabs.indexOf(tabId)
+ const activeTabIdx = openedTabs.indexOf(tabs.activeTab!)
const tabsToClose = openedTabs.slice(tabIdx + 1)
tabs.removeTabs(tabsToClose)
+
+ const isActiveTabClosed = tabIdx < activeTabIdx
+ if (isActiveTabClosed) {
+ const id = editor === 'table' ? tabId.split('-')[1] : tabId.split('sql-')[1]
+ router.push(`/project/${ref}/${editor === 'table' ? 'editor' : 'sql'}/${id}`)
+ }
}
}