Skip to content

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

Fix Table Editor non-existing table state (#35710)

Joshen Limbae178ace815
diff --git a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
index 1ba28f268e9..1f2de9163cc 100644
--- a/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
+++ b/apps/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
@@ -58,6 +58,7 @@ export const TableGridEditor = ({
const canEditColumns = useCheckPermissions(PermissionAction.TENANT_SQL_ADMIN_WRITE, 'columns')
const isReadOnly = !canEditTables && !canEditColumns
const tabId = !!id ? tabs.openTabs.find((x) => x.endsWith(id)) : undefined
+ const openTabs = tabs.openTabs.filter((x) => !x.startsWith('sql'))
const getTables = useGetTables({
projectRef: project?.ref,
diff --git a/apps/studio/components/layouts/Tabs/Tabs.tsx b/apps/studio/components/layouts/Tabs/Tabs.tsx
index 471d3496424..9cf7bd1ad4a 100644
--- a/apps/studio/components/layouts/Tabs/Tabs.tsx
+++ b/apps/studio/components/layouts/Tabs/Tabs.tsx
@@ -11,9 +11,8 @@ import { AnimatePresence, motion } from 'framer-motion'
import { Plus, X } from 'lucide-react'
import { useRouter } from 'next/router'
-import { LOCAL_STORAGE_KEYS, useParams } from 'common'
+import { useParams } from 'common'
import { TabsUpdateTooltip } from 'components/interfaces/App/FeaturePreview/TableEditorTabs'
-import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useAppStateSnapshot } from 'state/app-state'
import { editorEntityTypes, useTabsStateSnapshot, type Tab } from 'state/tabs'
import { cn, Tabs_Shadcn_, TabsList_Shadcn_, TabsTrigger_Shadcn_ } from 'ui'
@@ -37,11 +36,6 @@ export const EditorTabs = () => {
})
)
- const [tabsInterfaceAcknowledge, setTabsInterfaceAcknowledge] = useLocalStorageQuery(
- LOCAL_STORAGE_KEYS.TABS_INTERFACE_ACKNOWLEDGED,
- false
- )
-
const openTabs = tabs.openTabs
.map((id) => tabs.tabsMap[id])
.filter((tab) => tab !== undefined) as Tab[]
diff --git a/apps/studio/components/layouts/editors/EditorBaseLayout.tsx b/apps/studio/components/layouts/editors/EditorBaseLayout.tsx
index 72fe6c50c0b..eafb111c3b0 100644
--- a/apps/studio/components/layouts/editors/EditorBaseLayout.tsx
+++ b/apps/studio/components/layouts/editors/EditorBaseLayout.tsx
@@ -6,6 +6,7 @@ import {
useIsSQLEditorTabsEnabled,
useIsTableEditorTabsEnabled,
} from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { useTabsStateSnapshot } from 'state/tabs'
import { cn } from 'ui'
import { ProjectLayoutWithAuth } from '../ProjectLayout/ProjectLayout'
import { CollapseButton } from '../Tabs/CollapseButton'
@@ -23,16 +24,21 @@ export const EditorBaseLayout = ({ children, title, product, ...props }: Explore
const { ref } = useParams()
const pathname = usePathname()
const editor = useEditorType()
+ const tabs = useTabsStateSnapshot()
const isTableEditorTabsEnabled = useIsTableEditorTabsEnabled()
const isSQLEditorTabsEnabled = useIsSQLEditorTabsEnabled()
const tableEditorTabsEnabled = editor === 'table' && isTableEditorTabsEnabled
const sqlEditorTabsEnabled = editor === 'sql' && isSQLEditorTabsEnabled
- const hideTabs = pathname === `/project/${ref}/editor` || pathname === `/project/${ref}/sql`
+
+ const hasNoOpenTabs =
+ editor === 'table' ? tabs.openTabs.filter((x) => !x.startsWith('sql')).length === 0 : false
+ const hideTabs =
+ pathname === `/project/${ref}/editor` || pathname === `/project/${ref}/sql` || hasNoOpenTabs
return (
- <ProjectLayoutWithAuth resizableSidebar={true} title={title} product={product} {...props}>
+ <ProjectLayoutWithAuth resizableSidebar title={title} product={product} {...props}>
<div className="flex flex-col h-full">
{tableEditorTabsEnabled || sqlEditorTabsEnabled ? (
<div