Skip to content

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

Fix: SQL Editor browser back button navigation (#43043)

Vaibhavf8419ef9ae7c
diff --git a/apps/studio/pages/project/[ref]/sql/[id].tsx b/apps/studio/pages/project/[ref]/sql/[id].tsx
index 1b357e43ced..ca5388da5dc 100644
--- a/apps/studio/pages/project/[ref]/sql/[id].tsx
+++ b/apps/studio/pages/project/[ref]/sql/[id].tsx
@@ -69,7 +69,7 @@ const SqlEditor: NextPageWithLayout = () => {
snapV2.setSnippet(ref, data as unknown as SnippetWithContent)
} else {
setLastVisitedSnippet(undefined)
- router.push(`/project/${ref}/sql/new`)
+ router.replace(`/project/${ref}/sql/new`)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -84,7 +84,7 @@ const SqlEditor: NextPageWithLayout = () => {
content === undefined
) {
const snippet = allSnippets.find((snippet) => snippet.id === history.sql)
- if (snippet !== undefined) router.push(`/project/${ref}/sql/${history.sql}`)
+ if (snippet !== undefined) router.replace(`/project/${ref}/sql/${history.sql}`)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id, allSnippets, content])
diff --git a/apps/studio/pages/project/[ref]/sql/index.tsx b/apps/studio/pages/project/[ref]/sql/index.tsx
index 6a1062d86fd..6020e09108c 100644
--- a/apps/studio/pages/project/[ref]/sql/index.tsx
+++ b/apps/studio/pages/project/[ref]/sql/index.tsx
@@ -23,14 +23,14 @@ const SQLEditorIndexPage: NextPageWithLayout = () => {
const lastOpenedTab = history.sql
const lastTabId = store.openTabs.find((id) => store.tabsMap[id]?.type === 'sql')
if (lastOpenedTab !== undefined) {
- router.push(`/project/${projectRef}/sql/${history.sql}`)
+ router.replace(`/project/${projectRef}/sql/${history.sql}`)
} else if (lastTabId) {
const lastTab = store.tabsMap[lastTabId]
if (lastTab) {
- router.push(`/project/${projectRef}/sql/${lastTab.id.replace('sql-', '')}`)
+ router.replace(`/project/${projectRef}/sql/${lastTab.id.replace('sql-', '')}`)
}
} else {
- router.push(`/project/${projectRef}/sql/new`)
+ router.replace(`/project/${projectRef}/sql/new`)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps