Skip to content

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

fix: reset scroll (#46553)

Vaibhav0957932b1db2
diff --git a/apps/studio/components/layouts/ProjectLayout/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
index bff3522e1d0..adc6ee2d47c 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.test.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
@@ -126,6 +126,7 @@ vi.mock('../editors/EditorsLayout.hooks', () => ({
}))
vi.mock('../MainScrollContainerContext', () => ({
+ useMainScrollContainer: () => null,
useSetMainScrollContainer: () => () => {},
}))
diff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsx
index c7052c78529..7e831ada5f1 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx
@@ -25,7 +25,7 @@ import {
} from 'ui'
import { useEditorType } from '../editors/EditorsLayout.hooks'
-import { useSetMainScrollContainer } from '../MainScrollContainerContext'
+import { useMainScrollContainer, useSetMainScrollContainer } from '../MainScrollContainerContext'
import { useMobileSheet } from '../Navigation/NavigationBar/MobileSheetContext'
import ProductMenuBar from '../Navigation/ProductMenuBar'
import BuildingState from './BuildingState'
@@ -169,6 +169,7 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<Projec
const pathname = getPathnameWithoutQuery(router.asPath, router.pathname)
const currentSectionKey = getSectionKeyFromPathname(pathname)
+ const mainScrollContainer = useMainScrollContainer()
const setMainScrollContainer = useSetMainScrollContainer()
const combinedRef = mergeRefs(ref, setMainScrollContainer)
@@ -245,6 +246,10 @@ export const ProjectLayout = forwardRef<HTMLDivElement, PropsWithChildren<Projec
return unregister
}, [registerOpenMenu, productMenu, product, currentSectionKey, setMobileSheetContent])
+ useLayoutEffect(() => {
+ mainScrollContainer?.scrollTo({ top: 0, left: 0 })
+ }, [pathname, mainScrollContainer])
+
return (
<>
<Head>