The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore(studio): migrate combobox triggers (#50157)
Danny Whitefce9d475ee22
diff --git a/apps/studio/components/interfaces/Account/Preferences/TimezoneSettings.tsx b/apps/studio/components/interfaces/Account/Preferences/TimezoneSettings.tsxindex bc21899f4ab..e7be5ec816a 100644--- a/apps/studio/components/interfaces/Account/Preferences/TimezoneSettings.tsx+++ b/apps/studio/components/interfaces/Account/Preferences/TimezoneSettings.tsx@@ -1,11 +1,10 @@-import { useFlag } from 'common'-import { CheckIcon, ChevronsUpDown, Globe } from 'lucide-react'+import { CheckIcon, Globe } from 'lucide-react'import { useId, useMemo, useState } from 'react'import {- Button,Card,CardContent,cn,+ ComboboxTrigger,Command,CommandEmpty,CommandGroup,@@ -35,11 +34,10 @@ import { useTrack } from '@/lib/telemetry/track'const AUTO_OPTION_VALUE = '__auto__'export const TimezoneSettings = () => {- const timezonePickerEnabled = useFlag('timezonePicker')- const { timezone, storedTimezone, setTimezone, isAutoDetected } = useTimezone()const track = useTrack()- const [open, setOpen] = useState(false)const listboxId = useId()+ const [open, setOpen] = useState(false)+ const { timezone, storedTimezone, setTimezone, isAutoDetected } = useTimezone()// Browser timezone is captured once and stays stable even when the user has// overridden the dashboard timezone — that's the value the "Auto detect"@@ -48,8 +46,6 @@ export const TimezoneSettings = () => {const triggerLabel = useMemo(() => findTimezoneByIana(timezone)?.text ?? timezone, [timezone])- if (!timezonePickerEnabled) return null-const handleSelect = (nextStored: string) => {setTimezone(nextStored)const resolvedNext = nextStored || guessLocalTimezone()@@ -87,20 +83,19 @@ export const TimezoneSettings = () => {><Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>- <Button- role="combobox"+ <ComboboxTriggeraria-expanded={open}aria-controls={listboxId}- className="w-full justify-between"- variant="default"+ data-state={open ? 'open' : 'closed'}size="small"- icon={<Globe />}- iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} />}>- <span className="truncate text-left">- {isAutoDetected ? `Auto detect (${timezone})` : triggerLabel}+ <span className="flex min-w-0 items-center gap-2">+ <Globe aria-hidden="true" className="h-4 w-4 shrink-0" />+ <span className="truncate">+ {isAutoDetected ? `Auto detect (${timezone})` : triggerLabel}+ </span></span>- </Button>+ </ComboboxTrigger></PopoverTrigger><PopoverContent id={listboxId} className="w-[--radix-popover-trigger-width] p-0"><Command>diff --git a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AwsRegionSelector.tsx b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AwsRegionSelector.tsxindex c957e302795..3f2a22231ee 100644--- a/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AwsRegionSelector.tsx+++ b/apps/studio/components/interfaces/Auth/ThirdPartyAuthForm/AwsRegionSelector.tsx@@ -1,8 +1,8 @@-import { Check, ChevronsUpDown } from 'lucide-react'+import { Check } from 'lucide-react'import { useId, useState } from 'react'import {- Button,cn,+ ComboboxTrigger,Command,CommandEmpty,CommandGroup,@@ -62,19 +62,15 @@ export const AwsRegionSelector = ({<Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild><FormControl>- <Button- variant="default"- role="combobox"+ <ComboboxTriggeraria-expanded={open}aria-controls={listboxId}- className={cn('w-full justify-between', !value && 'text-muted-foreground')}+ data-state={open ? 'open' : 'closed'}+ className={cn(!value && 'text-muted-foreground')}size="small"- iconRight={- <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" strokeWidth={1} />- }>{value ?? 'Select a region'}- </Button>+ </ComboboxTrigger></FormControl></PopoverTrigger><PopoverContent id={listboxId} className="p-0" sameWidthAsTrigger>diff --git a/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx b/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsxindex 6a40d086032..935cb9478d9 100644--- a/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx+++ b/apps/studio/components/interfaces/Database/Backups/PITR/TimezoneSelection.tsx@@ -1,8 +1,8 @@-import { CheckIcon, ChevronsUpDown, Globe } from 'lucide-react'+import { CheckIcon, Globe } from 'lucide-react'import { useId, useState } from 'react'import {- Button,cn,+ ComboboxTrigger,Command,CommandEmpty,CommandGroup,@@ -36,20 +36,22 @@ export const TimezoneSelection = ({<div className="w-full"><Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>- <Button- role="combobox"+ <ComboboxTriggeraria-expanded={open}aria-controls={listboxId}- className="w-[350px] justify-start"+ data-state={open ? 'open' : 'closed'}+ className="w-[350px]"size="small"- variant="default"- icon={<Globe />}- iconRight={<ChevronsUpDown size={14} strokeWidth={1.5} className="ml-auto" />}>- {selectedTimezone- ? timezoneOptions.find((option) => option === selectedTimezone.text)- : 'Select timezone...'}- </Button>+ <span className="flex min-w-0 items-center gap-2">+ <Globe aria-hidden="true" className="h-4 w-4 shrink-0" />+ <span className="truncate">+ {selectedTimezone+ ? timezoneOptions.find((option) => option === selectedTimezone.text)+ : 'Select timezone...'}+ </span>+ </span>+ </ComboboxTrigger></PopoverTrigger><PopoverContent id={listboxId} className="w-[350px] p-0"><Command>diff --git a/apps/studio/components/ui/FunctionSelector.tsx b/apps/studio/components/ui/FunctionSelector.tsxindex 6fe750d8aad..16cb3979061 100644--- a/apps/studio/components/ui/FunctionSelector.tsx+++ b/apps/studio/components/ui/FunctionSelector.tsx@@ -1,12 +1,13 @@import { useParams } from 'common'import { uniqBy } from 'lodash'-import { Check, ChevronsUpDown, Plus } from 'lucide-react'+import { Check, Plus } from 'lucide-react'import { useState } from 'react'import {Alert,AlertDescription,AlertTitle,Button,+ ComboboxTrigger,Command,CommandEmpty,CommandGroup,@@ -97,26 +98,22 @@ const FunctionSelector = ({{isSuccess && (<Popover open={open} onOpenChange={setOpen} modal={false}><PopoverTrigger asChild>- <Button+ <ComboboxTriggersize={size}disabled={!!disabled}- variant="default"- className={`w-full [&>span]:w-full ${size === 'small' ? 'py-1.5' : ''}`}- iconRight={- <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />- }+ aria-expanded={open}+ data-state={open ? 'open' : 'closed'}+ className={size === 'small' ? 'py-1.5' : undefined}>{value ? (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">function:</p>- <p className="text-foreground">{value}</p>- </div>+ <span className="flex w-full gap-1">+ <span className="text-foreground-lighter">function:</span>+ <span className="text-foreground">{value}</span>+ </span>) : (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">Select a function</p>- </div>+ <span className="flex w-full gap-1 text-foreground-lighter">Select a function</span>)}- </Button>+ </ComboboxTrigger></PopoverTrigger><PopoverContent className="p-0" side="bottom" align="start" sameWidthAsTrigger><Command>diff --git a/apps/studio/components/ui/SchemaSelector.test.tsx b/apps/studio/components/ui/SchemaSelector.test.tsxindex 20500671f37..68ac121a6a0 100644--- a/apps/studio/components/ui/SchemaSelector.test.tsx+++ b/apps/studio/components/ui/SchemaSelector.test.tsx@@ -74,6 +74,14 @@ const renderAndOpenSelector = async () => {}describe('SchemaSelector', () => {+ it('gives the combobox an accessible name for the selected schema', async () => {+ mockProjectAndSchemas({ highAvailability: false })++ customRender(<SchemaSelector selectedSchemaName="public" onSelectSchema={vi.fn()} />)++ expect(await screen.findByRole('combobox', { name: 'Schema public' })).toBeInTheDocument()+ })+it('hides the multigres schema on high availability projects', async () => {mockProjectAndSchemas({ highAvailability: true })diff --git a/apps/studio/components/ui/SchemaSelector.tsx b/apps/studio/components/ui/SchemaSelector.tsxindex 2fe48fd54b3..922f68308f5 100644--- a/apps/studio/components/ui/SchemaSelector.tsx+++ b/apps/studio/components/ui/SchemaSelector.tsx@@ -1,11 +1,12 @@import { PermissionAction } from '@supabase/shared-types/out/constants'-import { Check, ChevronsUpDown, Plus } from 'lucide-react'+import { Check, Plus } from 'lucide-react'import { ComponentPropsWithoutRef, forwardRef, useMemo, useState } from 'react'import {Alert,AlertDescription,AlertTitle,Button,+ ComboboxTrigger,Command,CommandEmpty,CommandGroup,@@ -138,29 +139,32 @@ export const SchemaSelector = forwardRef<HTMLDivElement, SchemaSelectorProps>({isSchemasSuccess && (<Popover open={open} onOpenChange={setOpen} modal={false}><PopoverTrigger asChild>- <Button+ <ComboboxTriggersize={size}disabled={disabled}- variant="default"data-testid="schema-selector"- className={`w-full [&>span]:w-full pr-1! space-x-1`}- iconRight={- <ChevronsUpDown className="text-foreground-muted" strokeWidth={2} size={14} />+ aria-label={+ selectedSchemaName+ ? `Schema ${selectedSchemaName === '*' ? 'All schemas' : selectedSchemaName}`+ : placeholderLabel}+ aria-expanded={open}+ data-state={open ? 'open' : 'closed'}+ className={size === 'tiny' ? 'w-full pr-1.5!' : 'w-full'}>{selectedSchemaName ? (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">schema</p>- <p className="text-foreground">+ <span className="flex w-full gap-1">+ <span className="text-foreground-lighter">schema</span>+ <span className="text-foreground">{selectedSchemaName === '*' ? 'All schemas' : selectedSchemaName}- </p>- </div>+ </span>+ </span>) : (- <div className="w-full flex gap-1">- <p className="text-foreground-lighter">{placeholderLabel}</p>- </div>+ <span className="flex w-full gap-1 text-foreground-lighter">+ {placeholderLabel}+ </span>)}- </Button>+ </ComboboxTrigger></PopoverTrigger><PopoverContentclassName="p-0 min-w-[200px] pointer-events-auto"diff --git a/e2e/studio/features/rls-policies.spec.ts b/e2e/studio/features/rls-policies.spec.tsindex ff5f31fd02f..7c533179d17 100644--- a/e2e/studio/features/rls-policies.spec.ts+++ b/e2e/studio/features/rls-policies.spec.ts@@ -36,7 +36,7 @@ test.describe('RLS Policies', () => {).toBeVisible()// Check schema selector is present- await expect(page.getByRole('button', { name: 'schema public' })).toBeVisible()+ await expect(page.getByRole('combobox', { name: 'Schema public' })).toBeVisible()// Check search/filter input is presentawait expect(page.getByPlaceholder('Filter tables and policies')).toBeVisible()@@ -75,7 +75,7 @@ test.describe('RLS Policies', () => {await navigateToPoliciesPage(page, ref)// Click schema selector- await page.getByRole('button', { name: 'schema public' }).click()+ await page.getByRole('combobox', { name: 'Schema public' }).click()// Select auth schemaawait page.getByRole('option', { name: 'auth' }).click()@@ -85,7 +85,7 @@ test.describe('RLS Policies', () => {await expect(page.getByRole('heading', { name: 'users', exact: true })).toBeVisible()// Switch back to public- await page.getByRole('button', { name: 'schema auth' }).click()+ await page.getByRole('combobox', { name: 'Schema auth' }).click()await page.getByRole('option', { name: 'public', exact: true }).click()await page.waitForTimeout(1000)})