mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
## What kind of change does this PR introduce? Bug fix. ## What is the current behavior? A command dropdown cannot be scrolled by touch when it sits inside a dialog or sheet. Radix wraps a modal dialog's overlay in a scroll lock that cancels wheel and touch events whose target is not inside the sheet. A dropdown portals to the body, so it falls outside that boundary and its scroll events get cancelled. Callers have been rediscovering this one at a time and fixing only half of it. `MultiSelectorList` stops wheel events reaching the document, and `SchemaSelector` and `FunctionSelector` expose a `stopScrollPropagation` prop that does the same. None of them handle touch, so the desktop symptom is fixed everywhere and the mobile one is fixed nowhere. ## What is the new behavior? `CommandList` keeps wheel and touch events off the document itself. That covers every command dropdown in the monorepo, in an overlay or not, with no call-site changes. A caller's own `onWheel` or `onTouchMove` still runs. The workarounds this replaces are removed: the handler in `MultiSelectorList`, and the `stopScrollPropagation` prop on `SchemaSelector` and `FunctionSelector` along with its four call sites. One behavior change worth naming: overscrolling past the end of a dropdown no longer scrolls the page behind it. That is what a dropdown should do, and it is what the four `stopScrollPropagation` call sites were already opting into. #50072 depends on this. It swaps two selects for comboboxes, and Radix Select brings its own scroll lock, so without this the swap would regress touch scrolling. ## To test - On the deploy preview, [open a project's Connect sheet](https://studio-staging-git-dnywh-fix-multi-select-scrol-63608b-supabase.vercel.app/dashboard/project/_) and pick the MCP tab. - Narrow the window to phone width and switch on touch emulation in devtools. - Open the features dropdown and drag the list. It should scroll, and the sheet behind it should stay put. - Repeat with a mouse wheel to confirm desktop scrolling still works. - [Open Authentication > Hooks](https://studio-staging-git-dnywh-fix-multi-select-scrol-63608b-supabase.vercel.app/dashboard/project/_/auth/hooks) > Create hook, open the schema picker, and confirm it still scrolls by wheel now that `stopScrollPropagation` is gone. - [Open the SQL editor](https://studio-staging-git-dnywh-fix-multi-select-scrol-63608b-supabase.vercel.app/dashboard/project/_/sql/new)'s schema picker on a page with no overlay and confirm the list scrolls normally. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved wheel and touch scrolling behavior in command lists, selectors, and multi-select menus. - Reduced unwanted scroll-lock interference when using selectors inside overlays such as dialogs and sheets. - Preserved support for supplied scroll event callbacks. - **Accessibility** - Added clearer accessible labels to the Connect and mobile navigation menu buttons. - Updated the Connect button text behavior for icon-only and standard presentations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
153 lines
6.1 KiB
TypeScript
153 lines
6.1 KiB
TypeScript
import { useBreakpoint, useFlag, useParams } from 'common'
|
|
import { useRouter } from 'next/router'
|
|
import { PropsWithChildren, useEffect, useState } from 'react'
|
|
import { ResizablePanel, ResizablePanelGroup, SidebarProvider, usePanelRef } from 'ui'
|
|
import { SkipToContent } from 'ui-patterns/SkipToContent'
|
|
|
|
import { BannerStack } from '../ui/BannerStack/BannerStack'
|
|
import { LayoutHeader } from './Navigation/LayoutHeader/LayoutHeader'
|
|
import { MobileNavigationBar } from './Navigation/NavigationBar/MobileNavigationBar'
|
|
import { MobileSheetProvider } from './Navigation/NavigationBar/MobileSheetContext'
|
|
import { StudioMobileSheetNav } from './Navigation/NavigationBar/StudioMobileSheetNav'
|
|
import { LayoutSidebar } from './ProjectLayout/LayoutSidebar'
|
|
import {
|
|
LayoutSidebarProvider,
|
|
SIDEBAR_KEYS,
|
|
} from './ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
|
|
import { ProjectContextProvider } from './ProjectLayout/ProjectContext'
|
|
import { AppBannerWrapper } from '@/components/interfaces/App/AppBannerWrapper'
|
|
import { GitHubConfigDriftBanner } from '@/components/interfaces/App/GitHubConfigDriftBanner'
|
|
import { Sidebar } from '@/components/interfaces/Sidebar'
|
|
import { useSyncScopedIntrospection } from '@/data/scoped-introspection'
|
|
import { useLastVisitedOrganization } from '@/hooks/misc/useLastVisitedOrganization'
|
|
import { useCheckLatestDeploy } from '@/hooks/use-check-latest-deploy'
|
|
import { IS_PLATFORM } from '@/lib/constants'
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
import { useSidebarManagerSnapshot } from '@/state/sidebar-manager-state'
|
|
|
|
export interface DefaultLayoutProps {
|
|
headerTitle?: string
|
|
hideMobileMenu?: boolean
|
|
}
|
|
|
|
/**
|
|
* Base layout for all project pages in the dashboard, rendered as the first child on all page files within a project.
|
|
*
|
|
* A second layout as the child to this is required, and the layout depends on which section of the dashboard the page is on. (e.g Auth - AuthLayout)
|
|
*
|
|
* The base layout handles rendering the following UI components:
|
|
* - App banner (e.g for notices or incidents)
|
|
* - Mobile navigation bar
|
|
* - First level side navigation bar (e.g For navigating to Table Editor, SQL Editor, Database page, etc)
|
|
*/
|
|
export const DefaultLayout = ({
|
|
children,
|
|
headerTitle,
|
|
hideMobileMenu,
|
|
}: PropsWithChildren<DefaultLayoutProps>) => {
|
|
useSyncScopedIntrospection()
|
|
useCheckLatestDeploy()
|
|
|
|
const { ref } = useParams()
|
|
const router = useRouter()
|
|
const panelRef = usePanelRef()
|
|
const isMobile = useBreakpoint('md')
|
|
const appSnap = useAppStateSnapshot()
|
|
const { isMaximised, activeSidebar } = useSidebarManagerSnapshot()
|
|
const { lastVisitedOrganization } = useLastVisitedOrganization()
|
|
const showConfigDrift = useFlag('ConfigDrift') && IS_PLATFORM
|
|
|
|
const [isMounted, setIsMounted] = useState(false)
|
|
|
|
const backToDashboardURL = router.pathname.startsWith('/account')
|
|
? appSnap.lastRouteBeforeVisitingAccountPage.length > 0
|
|
? appSnap.lastRouteBeforeVisitingAccountPage
|
|
: IS_PLATFORM && !!lastVisitedOrganization
|
|
? `/org/${lastVisitedOrganization}`
|
|
: IS_PLATFORM
|
|
? '/organizations'
|
|
: '/project/default'
|
|
: undefined
|
|
|
|
const contentMinSizePercentage = 50
|
|
const contentMaxSizePercentage = 70
|
|
|
|
useEffect(() => {
|
|
setIsMounted(true)
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (!isMounted || !panelRef.current || !activeSidebar || isMobile) return
|
|
if (isMaximised) {
|
|
panelRef.current.collapse()
|
|
} else {
|
|
panelRef.current.resize(`${contentMaxSizePercentage}%`)
|
|
}
|
|
}, [isMounted, isMaximised, panelRef, activeSidebar, isMobile])
|
|
|
|
// This is required to prevent layout shift when rendering resizable panels (they initially render at 50%, then shift
|
|
// to whatever is specified).
|
|
if (!isMounted) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<SidebarProvider defaultOpen={false}>
|
|
<LayoutSidebarProvider>
|
|
<ProjectContextProvider projectRef={ref}>
|
|
<MobileSheetProvider>
|
|
<div className="flex flex-col h-screen w-screen">
|
|
<SkipToContent href="#main" />
|
|
{/* Top Banner */}
|
|
<AppBannerWrapper />
|
|
<div className="shrink-0">
|
|
{isMobile && (
|
|
<MobileNavigationBar
|
|
hideMobileMenu={hideMobileMenu}
|
|
backToDashboardURL={backToDashboardURL}
|
|
/>
|
|
)}
|
|
<LayoutHeader headerTitle={headerTitle} backToDashboardURL={backToDashboardURL} />
|
|
{showConfigDrift && ref && <GitHubConfigDriftBanner />}
|
|
</div>
|
|
{/* Main Content Area */}
|
|
<div className="flex flex-1 w-full overflow-y-hidden">
|
|
{/* Sidebar - Only show for project pages, not account pages */}
|
|
{!router.pathname.startsWith('/account') && <Sidebar />}
|
|
{/* Main Content with Layout Sidebar */}
|
|
<ResizablePanelGroup
|
|
orientation="horizontal"
|
|
className="h-full w-full overflow-x-hidden flex-1 flex flex-row gap-0"
|
|
autoSaveId="default-layout-content"
|
|
>
|
|
<ResizablePanel
|
|
id="panel-content"
|
|
className="w-full"
|
|
panelRef={panelRef}
|
|
collapsible={activeSidebar?.id === SIDEBAR_KEYS.AI_ASSISTANT}
|
|
minSize={`${contentMinSizePercentage}`}
|
|
maxSize={`${contentMaxSizePercentage}`}
|
|
defaultSize={`${contentMaxSizePercentage}`}
|
|
>
|
|
<main id="main" tabIndex={-1} className="h-full overflow-y-auto outline-hidden">
|
|
{children}
|
|
</main>
|
|
</ResizablePanel>
|
|
<LayoutSidebar
|
|
minSize={`${100 - contentMaxSizePercentage}`}
|
|
maxSize="100"
|
|
defaultSize={`${100 - contentMaxSizePercentage}`}
|
|
/>
|
|
</ResizablePanelGroup>
|
|
</div>
|
|
</div>
|
|
|
|
<BannerStack />
|
|
<StudioMobileSheetNav />
|
|
</MobileSheetProvider>
|
|
</ProjectContextProvider>
|
|
</LayoutSidebarProvider>
|
|
</SidebarProvider>
|
|
)
|
|
}
|