Skip to content

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

fix: prevent scroll when banners are visible in AppLayout components (#21069)

Mohammed Yasin Mulla497575b6479b
diff --git a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx b/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
index 757d2ebcfab..8c4aa827cd7 100644
--- a/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
+++ b/apps/studio/components/interfaces/App/AppBannerWrapper.tsx
@@ -1,10 +1,11 @@
import { useMonaco } from '@monaco-editor/react'
import { useTheme } from 'next-themes'
+import { PropsWithChildren, useEffect } from 'react'
+
import IncidentBanner from 'components/layouts/AppLayout/IncidentBanner'
+import { NoticeBanner } from 'components/layouts/AppLayout/NoticeBanner'
import { getTheme } from 'components/ui/CodeEditor'
import { useFlag } from 'hooks'
-import { PropsWithChildren, useEffect } from 'react'
-import { NoticeBanner } from 'components/layouts/AppLayout/NoticeBanner'
const AppBannerWrapper = ({ children }: PropsWithChildren<{}>) => {
const monaco = useMonaco()
@@ -22,8 +23,10 @@ const AppBannerWrapper = ({ children }: PropsWithChildren<{}>) => {
return (
<div className="min-h-full flex flex-col">
- {ongoingIncident && <IncidentBanner />}
- {showNoticeBanner && <NoticeBanner />}
+ <div className="flex-none">
+ {ongoingIncident && <IncidentBanner />}
+ {showNoticeBanner && <NoticeBanner />}
+ </div>
{children}
</div>
)
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
index bd5d76de274..c8c652542b7 100644
--- a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -9,7 +9,6 @@ import { IS_PLATFORM } from 'lib/constants'
import SettingsLayout from '../SettingsLayout/SettingsLayout'
import { SidebarSection } from './AccountLayout.types'
import WithSidebar from './WithSidebar'
-import { LayoutWrapper } from '../LayoutWrapper'
export interface AccountLayoutProps {
title: string
@@ -151,8 +150,8 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
<title>{title ? `${title} | Supabase` : 'Supabase'}</title>
<meta name="description" content="Supabase Studio" />
</Head>
- <div className="flex h-full">
- <LayoutWrapper className="flex flex-col flex-1 w-full overflow-y-auto">
+ <div className="h-full min-h-[0px] basis-0 flex-1">
+ <div className="flex flex-col h-full min-h-[0px] basis-0 flex-1">
<WithSidebar
hideSidebar={navLayoutV2}
title={title}
@@ -161,7 +160,7 @@ const AccountLayout = ({ children, title, breadcrumbs }: PropsWithChildren<Accou
>
{children}
</WithSidebar>
- </LayoutWrapper>
+ </div>
</div>
</>
)
diff --git a/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx b/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx
index 844aca124fe..50063e4c1d4 100644
--- a/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx
+++ b/apps/studio/components/layouts/AccountLayout/WithSidebar.tsx
@@ -4,7 +4,6 @@ import { ReactNode } from 'react'
import { Badge, IconArrowUpRight, IconLogOut, Menu } from 'ui'
import { useFlag } from 'hooks'
-import { LayoutWrapper } from '../LayoutWrapper'
import LayoutHeader from '../ProjectLayout/LayoutHeader'
import { SidebarLink, SidebarSection } from './AccountLayout.types'
@@ -37,7 +36,7 @@ const WithSidebar = ({
return (
<div className="flex max-h-full">
{!hideSidebar && !noContent && (
- <LayoutWrapper
+ <div
id="with-sidebar"
className={[
'h-full bg-background',
@@ -77,7 +76,7 @@ const WithSidebar = ({
})}
</Menu>
</div>
- </LayoutWrapper>
+ </div>
)}
<div className="flex flex-1 flex-col">
{!navLayoutV2 && <LayoutHeader breadcrumbs={breadcrumbs} />}
diff --git a/apps/studio/components/layouts/AppLayout/AppLayout.tsx b/apps/studio/components/layouts/AppLayout/AppLayout.tsx
index 7ed065414ee..b8569dfd6c3 100644
--- a/apps/studio/components/layouts/AppLayout/AppLayout.tsx
+++ b/apps/studio/components/layouts/AppLayout/AppLayout.tsx
@@ -1,25 +1,15 @@
import { PropsWithChildren } from 'react'
-import { useIsNoticeBannerShown } from 'components/interfaces/App/AppBannerWrapperContext'
import { useFlag } from 'hooks'
import AppHeader from './AppHeader'
const AppLayout = ({ children }: PropsWithChildren<{}>) => {
const navLayoutV2 = useFlag('navigationLayoutV2')
- const ongoingIncident = useFlag('ongoingIncident')
- const showNoticeBanner = useFlag('showNoticeBanner')
-
- const noticeAcknowledged = useIsNoticeBannerShown()
-
- const appHeaderHeight = navLayoutV2 ? 49 : 0
- const bannerHeight =
- [ongoingIncident, showNoticeBanner && !noticeAcknowledged].filter(Boolean).length * 44
- const maxHeight = `calc(100vh - ${bannerHeight}px - ${appHeaderHeight}px)`
return (
- <div>
+ <div className="h-full min-h-[0px] basis-0 flex-1">
{navLayoutV2 && <AppHeader />}
- <div style={{ maxHeight, height: maxHeight }}>{children}</div>
+ {children}
</div>
)
}
diff --git a/apps/studio/components/layouts/IntegrationsLayout/IntegrationWindowLayout.tsx b/apps/studio/components/layouts/IntegrationsLayout/IntegrationWindowLayout.tsx
index 8e92a748ae4..09a1e48498a 100644
--- a/apps/studio/components/layouts/IntegrationsLayout/IntegrationWindowLayout.tsx
+++ b/apps/studio/components/layouts/IntegrationsLayout/IntegrationWindowLayout.tsx
@@ -4,7 +4,6 @@ import { IconBook, IconLifeBuoy, IconX, LoadingLine, cn } from 'ui'
import { withAuth } from 'hooks'
import { BASE_PATH } from 'lib/constants'
-import { LayoutWrapper } from '../LayoutWrapper'
import { ScaffoldContainer } from '../Scaffold'
export type IntegrationWindowLayoutProps = {
@@ -22,7 +21,7 @@ const IntegrationWindowLayout = ({
docsHref,
}: PropsWithChildren<IntegrationWindowLayoutProps>) => {
return (
- <LayoutWrapper className="flex w-full flex-col">
+ <div className="flex w-full flex-col">
<Header title={title} integrationIcon={integrationIcon} />
<LoadingLine loading={loading} />
<main className="overflow-auto flex flex-col h-full bg">{children}</main>
@@ -48,7 +47,7 @@ const IntegrationWindowLayout = ({
Support
</Link>
</ScaffoldContainer>
- </LayoutWrapper>
+ </div>
)
}
diff --git a/apps/studio/components/layouts/LayoutWrapper.tsx b/apps/studio/components/layouts/LayoutWrapper.tsx
deleted file mode 100644
index 29f9c820395..00000000000
--- a/apps/studio/components/layouts/LayoutWrapper.tsx
+++ /dev/null
@@ -1,30 +0,0 @@
-import { useIsNoticeBannerShown } from 'components/interfaces/App/AppBannerWrapperContext'
-import { useFlag } from 'hooks'
-import { PropsWithChildren } from 'react'
-
-interface LayoutWrapperProps {
- id?: string
- className?: string
-}
-
-export const LayoutWrapper = ({
- id,
- className,
- children,
-}: PropsWithChildren<LayoutWrapperProps>) => {
- const ongoingIncident = useFlag('ongoingIncident')
- const showNoticeBanner = useFlag('showNoticeBanner')
-
- const noticeAcknowledged = useIsNoticeBannerShown()
-
- const numBanners = [ongoingIncident, showNoticeBanner && !noticeAcknowledged].filter(
- Boolean
- ).length
- const maxHeight = `calc(100vh - ${numBanners * 44}px)`
-
- return (
- <div id={id} className={className} style={{ height: maxHeight, maxHeight }}>
- {children}
- </div>
- )
-}
diff --git a/apps/studio/components/layouts/WizardLayout.tsx b/apps/studio/components/layouts/WizardLayout.tsx
index ca47d0176c8..3685006886f 100644
--- a/apps/studio/components/layouts/WizardLayout.tsx
+++ b/apps/studio/components/layouts/WizardLayout.tsx
@@ -6,7 +6,6 @@ import { IconChevronRight } from 'ui'
import { withAuth } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { Organization, Project } from 'types'
-import { LayoutWrapper } from './LayoutWrapper'
import FeedbackDropdown from './ProjectLayout/LayoutHeader/FeedbackDropdown'
import HelpPopover from './ProjectLayout/LayoutHeader/HelpPopover'
@@ -21,14 +20,14 @@ const WizardLayout = ({
children,
}: PropsWithChildren<WizardLayoutProps>) => {
return (
- <LayoutWrapper className="flex w-full flex-col">
+ <div className="flex w-full flex-col">
<Header organization={organization} project={project} />
<div className="overflow-auto">
<section className="has-slide-in slide-in relative mx-auto my-10 max-w-2xl">
{children}
</section>
</div>
- </LayoutWrapper>
+ </div>
)
}
diff --git a/apps/studio/pages/support/new.tsx b/apps/studio/pages/support/new.tsx
index 966b277c320..1bdc6e20dcd 100644
--- a/apps/studio/pages/support/new.tsx
+++ b/apps/studio/pages/support/new.tsx
@@ -7,7 +7,6 @@ import { Button, IconLoader, IconTool } from 'ui'
import Success from 'components/interfaces/Support/Success'
import SupportForm from 'components/interfaces/Support/SupportForm'
-import { LayoutWrapper } from 'components/layouts/LayoutWrapper'
import { usePlatformStatusQuery } from 'data/platform/platform-status-query'
import { withAuth } from 'hooks'
import { BASE_PATH } from 'lib/constants'
@@ -18,7 +17,7 @@ const SupportPage = () => {
const isHealthy = data?.isHealthy
return (
- <LayoutWrapper className="relative flex overflow-y-auto overflow-x-hidden">
+ <div className="relative flex overflow-y-auto overflow-x-hidden">
<div className="mx-auto my-8 max-w-2xl px-4 lg:px-6">
<div className="space-y-12 py-8">
<div className="flex justify-between items-center">
@@ -91,7 +90,7 @@ const SupportPage = () => {
</div>
</div>
</div>
- </LayoutWrapper>
+ </div>
)
}