Skip to content

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

fix(ui): let command dropdowns scroll on touch inside overlays (#50103)

Danny Whitef5d0bf5d98da
diff --git a/apps/studio/components/interfaces/Auth/Hooks/CreateHookSheet.tsx b/apps/studio/components/interfaces/Auth/Hooks/CreateHookSheet.tsx
index aff0fed0421..cd0c3ef6f64 100644
--- a/apps/studio/components/interfaces/Auth/Hooks/CreateHookSheet.tsx
+++ b/apps/studio/components/interfaces/Auth/Hooks/CreateHookSheet.tsx
@@ -410,7 +410,6 @@ revoke execute on function ${ident(schema)}.${ident(functionName)} from authenti
<SchemaSelector
size="small"
showError={false}
- stopScrollPropagation
selectedSchemaName={field.value}
onSelectSchema={(name) => field.onChange(name)}
disabled={field.disabled}
@@ -435,7 +434,6 @@ revoke execute on function ${ident(schema)}.${ident(functionName)} from authenti
size="small"
schema={postgresValues.schema}
value={field.value}
- stopScrollPropagation
onChange={field.onChange}
disabled={field.disabled}
filterFunction={(func) => {
diff --git a/apps/studio/components/interfaces/ConnectButton/ConnectButton.tsx b/apps/studio/components/interfaces/ConnectButton/ConnectButton.tsx
index 6c9074f736b..03e0d836da0 100644
--- a/apps/studio/components/interfaces/ConnectButton/ConnectButton.tsx
+++ b/apps/studio/components/interfaces/ConnectButton/ConnectButton.tsx
@@ -41,6 +41,7 @@ export const ConnectButton = ({
>
<Button
variant={buttonVariant}
+ aria-label="Connect"
disabled={!isActiveHealthy}
className={cn('rounded-full', className)}
icon={<Plug className="rotate-90" />}
@@ -50,7 +51,7 @@ export const ConnectButton = ({
setShowConnect(true)
}}
>
- <span className={cn({ 'sr-only': iconOnly })}>Connect</span>
+ {!iconOnly && <span>Connect</span>}
</Button>
</ShortcutTooltip>
)
diff --git a/apps/studio/components/interfaces/Integrations/CronJobs/SqlFunctionSection.tsx b/apps/studio/components/interfaces/Integrations/CronJobs/SqlFunctionSection.tsx
index 931be8d92ee..23212f013a5 100644
--- a/apps/studio/components/interfaces/Integrations/CronJobs/SqlFunctionSection.tsx
+++ b/apps/studio/components/interfaces/Integrations/CronJobs/SqlFunctionSection.tsx
@@ -24,7 +24,6 @@ export const SqlFunctionSection = ({ form }: SqlFunctionSectionProps) => {
size="small"
className="w-56 2xl:w-full"
selectedSchemaName={field.value}
- stopScrollPropagation
onSelectSchema={(name) => {
field.onChange(name)
// deselect the selected function when the schema is changed
@@ -45,7 +44,6 @@ export const SqlFunctionSection = ({ form }: SqlFunctionSectionProps) => {
className="w-56 2xl:w-full"
schema={schema}
value={field.value}
- stopScrollPropagation
onChange={(name) => field.onChange(name)}
/>
</FormItemLayout>
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsx
index a5d920e4b97..657b39766fb 100644
--- a/apps/studio/components/layouts/DefaultLayout.tsx
+++ b/apps/studio/components/layouts/DefaultLayout.tsx
@@ -6,7 +6,7 @@ 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 { MobileNavigationBar } from './Navigation/NavigationBar/MobileNavigationBar'
import { MobileSheetProvider } from './Navigation/NavigationBar/MobileSheetContext'
import { StudioMobileSheetNav } from './Navigation/NavigationBar/StudioMobileSheetNav'
import { LayoutSidebar } from './ProjectLayout/LayoutSidebar'
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
index 82db548a6b5..e66c596d606 100644
--- a/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
@@ -21,7 +21,7 @@ import { IS_PLATFORM } from '@/lib/constants'
export const ICON_SIZE = 20
export const ICON_STROKE_WIDTH = 1.5
-const MobileNavigationBar = ({
+export const MobileNavigationBar = ({
hideMobileMenu,
backToDashboardURL,
}: {
@@ -73,6 +73,7 @@ const MobileNavigationBar = ({
{IS_PLATFORM ? <UserDropdown /> : <LocalDropdown />}
{!hideMobileMenu && (
<Button
+ aria-label="Open menu"
title="Menu dropdown button"
variant="default"
className="flex lg:hidden border-default bg-surface-100/75 text-foreground-light rounded-md min-w-[30px] w-[30px] h-[30px] data-open:bg-overlay-hover/30"
@@ -89,5 +90,3 @@ const MobileNavigationBar = ({
</div>
)
}
-
-export default MobileNavigationBar
diff --git a/apps/studio/components/ui/FunctionSelector.tsx b/apps/studio/components/ui/FunctionSelector.tsx
index 90c7410f181..6fe750d8aad 100644
--- a/apps/studio/components/ui/FunctionSelector.tsx
+++ b/apps/studio/components/ui/FunctionSelector.tsx
@@ -37,7 +37,6 @@ interface FunctionSelectorProps {
value: string
onChange: (value: string) => void
disabled?: boolean
- stopScrollPropagation?: boolean
// used to filter the functions by a criteria
filterFunction?: (func: DatabaseFunction) => boolean
noResultsLabel?: React.ReactNode
@@ -51,7 +50,6 @@ const FunctionSelector = ({
schema,
value,
onChange,
- stopScrollPropagation = false,
filterFunction = () => true,
noResultsLabel = <span>No functions found in this schema.</span>,
}: FunctionSelectorProps) => {
@@ -123,9 +121,7 @@ const FunctionSelector = ({
<PopoverContent className="p-0" side="bottom" align="start" sameWidthAsTrigger>
<Command>
<CommandInput placeholder="Search functions..." />
- <CommandList
- onWheel={stopScrollPropagation ? (event) => event.stopPropagation() : undefined}
- >
+ <CommandList>
<CommandEmpty>No functions found</CommandEmpty>
<CommandGroup>
<ScrollArea className={(functions || []).length > 7 ? 'h-[210px]' : ''}>
diff --git a/apps/studio/components/ui/SchemaSelector.tsx b/apps/studio/components/ui/SchemaSelector.tsx
index d7cd9d1a0c3..2fe48fd54b3 100644
--- a/apps/studio/components/ui/SchemaSelector.tsx
+++ b/apps/studio/components/ui/SchemaSelector.tsx
@@ -34,7 +34,6 @@ type SchemaSelectorProps = Omit<ComponentPropsWithoutRef<'div'>, 'onSelect'> & {
placeholderLabel?: string
supportSelectAll?: boolean
excludedSchemas?: string[]
- stopScrollPropagation?: boolean
onSelectSchema: (name: string) => void
onSelectCreateSchema?: () => void
align?: 'start' | 'end'
@@ -55,7 +54,6 @@ export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(
placeholderLabel = 'Choose a schema...',
supportSelectAll = false,
excludedSchemas = DEFAULT_EXCLUDED_SCHEMAS,
- stopScrollPropagation = false,
onSelectSchema,
onSelectCreateSchema,
align = 'start',
@@ -172,9 +170,7 @@ export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>(
>
<Command>
<CommandInput className="text-xs" placeholder="Find schema..." />
- <CommandList
- onWheel={stopScrollPropagation ? (event) => event.stopPropagation() : undefined}
- >
+ <CommandList>
<CommandEmpty>No schemas found</CommandEmpty>
<CommandGroup>
<ScrollArea className={(schemas || []).length > 7 ? 'h-[210px]' : ''}>
diff --git a/packages/ui-patterns/src/multi-select/multi-select.tsx b/packages/ui-patterns/src/multi-select/multi-select.tsx
index 2cc2a4c5970..a26425c0220 100644
--- a/packages/ui-patterns/src/multi-select/multi-select.tsx
+++ b/packages/ui-patterns/src/multi-select/multi-select.tsx
@@ -669,7 +669,6 @@ const MultiSelectorList = React.forwardRef<
style={{
maxHeight: `min(${dropdownMaxHeight}px, calc(var(--radix-popover-content-available-height) - ${DROPDOWN_BORDER_HEIGHT}px))`,
}}
- onWheel={(e) => e.stopPropagation()}
{...props}
>
<SelectionListState
diff --git a/packages/ui/src/components/shadcn/ui/command.tsx b/packages/ui/src/components/shadcn/ui/command.tsx
index f414dc31c05..a52e0c8d8ac 100644
--- a/packages/ui/src/components/shadcn/ui/command.tsx
+++ b/packages/ui/src/components/shadcn/ui/command.tsx
@@ -90,10 +90,21 @@ CommandInput.displayName = CommandPrimitive.Input.displayName
const CommandList = React.forwardRef<
React.ElementRef<typeof CommandPrimitive.List>,
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
->(({ className, ...props }, ref) => (
+>(({ className, onWheel, onTouchMove, ...props }, ref) => (
<CommandPrimitive.List
ref={ref}
className={cn('max-h-full overflow-y-auto overflow-x-hidden', className)}
+ // A dialog or sheet locks scrolling by cancelling wheel and touch events that land outside
+ // it, and a dropdown portals to the body. Keeping both off the document is what lets the
+ // list scroll with a trackpad and with a finger while an overlay is open.
+ onWheel={(event) => {
+ event.stopPropagation()
+ onWheel?.(event)
+ }}
+ onTouchMove={(event) => {
+ event.stopPropagation()
+ onTouchMove?.(event)
+ }}
{...props}
/>
))