mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
f5d0bf5d98
## 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>
82 lines
2.4 KiB
TypeScript
82 lines
2.4 KiB
TypeScript
import { Plug } from 'lucide-react'
|
|
import { parseAsBoolean, useQueryState } from 'nuqs'
|
|
import { ComponentProps } from 'react'
|
|
import { Button, cn } from 'ui'
|
|
|
|
import { ButtonTooltip } from '@/components/ui/ButtonTooltip'
|
|
import { ShortcutTooltip } from '@/components/ui/ShortcutTooltip'
|
|
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
|
|
import { PROJECT_STATUS } from '@/lib/constants'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
import { useAppStateSnapshot } from '@/state/app-state'
|
|
import { SHORTCUT_IDS } from '@/state/shortcuts/registry'
|
|
|
|
interface ConnectButtonProps {
|
|
buttonVariant?: ComponentProps<typeof Button>['variant']
|
|
className?: string
|
|
iconOnly?: boolean
|
|
}
|
|
|
|
export const ConnectButton = ({
|
|
buttonVariant = 'default',
|
|
className,
|
|
iconOnly = false,
|
|
}: ConnectButtonProps) => {
|
|
const { data: selectedProject } = useSelectedProjectQuery()
|
|
const { setConnectSheetSource } = useAppStateSnapshot()
|
|
const isActiveHealthy = selectedProject?.status === PROJECT_STATUS.ACTIVE_HEALTHY
|
|
const track = useTrack()
|
|
|
|
const [showConnect, setShowConnect] = useQueryState(
|
|
'showConnect',
|
|
parseAsBoolean.withDefault(false)
|
|
)
|
|
|
|
if (isActiveHealthy) {
|
|
return (
|
|
<ShortcutTooltip
|
|
shortcutId={SHORTCUT_IDS.CONNECT_OPEN_SHEET}
|
|
side="bottom"
|
|
open={showConnect ? false : undefined}
|
|
>
|
|
<Button
|
|
variant={buttonVariant}
|
|
aria-label="Connect"
|
|
disabled={!isActiveHealthy}
|
|
className={cn('rounded-full', className)}
|
|
icon={<Plug className="rotate-90" />}
|
|
onClick={() => {
|
|
track('header_connect_button_clicked')
|
|
setConnectSheetSource('header_button')
|
|
setShowConnect(true)
|
|
}}
|
|
>
|
|
{!iconOnly && <span>Connect</span>}
|
|
</Button>
|
|
</ShortcutTooltip>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ButtonTooltip
|
|
variant={buttonVariant}
|
|
disabled
|
|
className={cn('rounded-full', className)}
|
|
icon={<Plug className="rotate-90" />}
|
|
onClick={() => {
|
|
track('header_connect_button_clicked')
|
|
setConnectSheetSource('header_button')
|
|
setShowConnect(true)
|
|
}}
|
|
tooltip={{
|
|
content: {
|
|
side: 'bottom',
|
|
text: 'Project is currently not active and cannot be connected',
|
|
},
|
|
}}
|
|
>
|
|
<span className={cn({ 'sr-only': iconOnly })}>Connect</span>
|
|
</ButtonTooltip>
|
|
)
|
|
}
|