mirror of
https://github.com/supabase/supabase.git
synced 2026-09-10 03:51:51 +08:00
## Problem The `<RadioGroupCard>` component has an accessibility issue: duplicate ids on the items. Besides, its usage in the Design System app has additional issue: no label on the group itself when used outside a react-hook-form. Finally, the form example wrap each item in a `FormField` and `FormControl` which is unnecessary and causes another accessibility issue as all items are then injected the same `id` prop. ## Solution - Fix the duplicate ids issue - Fix all design system example - Fix the only wrong usage we have in studio No visual changes ## Notes When used outside a form, I added aria-label attributes on the group and they are announced by Mac Voice Over. However, when used in a form, our components adds a label with the correct for attribute but it seems that Mac Voice Over does not announce it. Not sure about how this should be handled. ## How to test On https://design-system-git-fix-radio-group-card-a11y-supabase.vercel.app/design-system/docs/components/radio-group-card, with Voice Over enabled: - tab to the first radio group, it should announce the value and the label of group itself, _Size_ - tab to the second, same but label is _Theme_ On https://design-system-git-fix-radio-group-card-a11y-supabase.vercel.app/design-system/docs/components/radio-group-card#form (Form example): - select any option and submit - check the correct option is submitted On https://studio-staging-git-fix-radio-group-card-a11y-supabase.vercel.app: - Go to your organization settings, Audit Log Drains, open your devtool network tab - Create a new custom endpoint and select the HTTP version - Check in the network tab that the correct http version is passed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Accessibility** * Improved labeling for radio card groups, including size, spacing, theme, and webhook version selections. * Radio options now use stable or automatically generated identifiers with reliable label associations. * **Bug Fixes** * Simplified radio option structure in forms for more consistent behavior. * Improved ID handling across radio card, stacked, and large radio options. * Updated the themed radio card example to use the dark theme by default. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
120 lines
4.7 KiB
TypeScript
120 lines
4.7 KiB
TypeScript
import { useFlag } from 'common'
|
|
import { UseFormReturn } from 'react-hook-form'
|
|
import {
|
|
Badge,
|
|
cn,
|
|
FormControl,
|
|
FormField,
|
|
FormItem,
|
|
RadioGroupStacked,
|
|
RadioGroupStackedItem,
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from 'ui'
|
|
import { Admonition } from 'ui-patterns/Admonition'
|
|
import { CollapsibleCardSection } from 'ui-patterns/CollapsibleCardSection'
|
|
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
|
|
|
|
import { CreateProjectForm } from './ProjectCreation.schema'
|
|
import { DocsButton } from '@/components/ui/DocsButton'
|
|
import Panel from '@/components/ui/Panel'
|
|
import { DOCS_URL } from '@/lib/constants'
|
|
|
|
interface AdvancedConfigurationProps {
|
|
form: UseFormReturn<CreateProjectForm>
|
|
}
|
|
|
|
export const AdvancedConfiguration = ({ form }: AdvancedConfigurationProps) => {
|
|
const disableOrioleProjectCreation = useFlag('disableOrioleProjectCreation')
|
|
|
|
return (
|
|
<Panel.Content>
|
|
<CollapsibleCardSection
|
|
title="Advanced Configuration"
|
|
description="These settings cannot be changed after the project is created"
|
|
>
|
|
<FormField
|
|
name="useOrioleDb"
|
|
control={form.control}
|
|
render={({ field }) => (
|
|
<>
|
|
<FormItemLayout
|
|
layout="horizontal"
|
|
label="Postgres Type"
|
|
className="[&>div>label]:break-normal!"
|
|
>
|
|
<FormControl>
|
|
<RadioGroupStacked
|
|
// Due to radio group not supporting boolean values
|
|
// value is converted to boolean
|
|
onValueChange={(value) => field.onChange(value === 'true')}
|
|
defaultValue={field.value.toString()}
|
|
>
|
|
<FormItem asChild>
|
|
<FormControl>
|
|
<RadioGroupStackedItem
|
|
value="false"
|
|
// @ts-ignore
|
|
label={
|
|
<>
|
|
Postgres
|
|
<Badge>Default</Badge>
|
|
</>
|
|
}
|
|
description="Recommended for production workloads"
|
|
className="[&>div>div>p]:text-left [&>div>div>p]:text-xs [&>div>div>div]:flex [&>div>div>div]:items-center [&>div>div>div]:gap-x-2"
|
|
/>
|
|
</FormControl>
|
|
</FormItem>
|
|
<FormItem asChild>
|
|
<FormControl>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<RadioGroupStackedItem
|
|
value="true"
|
|
// @ts-ignore
|
|
label={
|
|
<>
|
|
Postgres with OrioleDB
|
|
<Badge variant="warning">Alpha</Badge>
|
|
</>
|
|
}
|
|
description="Not recommended for production workloads"
|
|
className={cn(
|
|
'[&>div>div>p]:text-left [&>div>div>p]:text-xs [&>div>div>div]:flex [&>div>div>div]:items-center [&>div>div>div]:gap-x-2',
|
|
form.getValues('useOrioleDb') ? 'rounded-b-none!' : ''
|
|
)}
|
|
disabled={disableOrioleProjectCreation}
|
|
/>
|
|
</TooltipTrigger>
|
|
{disableOrioleProjectCreation && (
|
|
<TooltipContent side="right" className="w-60 text-center">
|
|
OrioleDB is temporarily disabled for new projects. Please try again
|
|
later.
|
|
</TooltipContent>
|
|
)}
|
|
</Tooltip>
|
|
</FormControl>
|
|
</FormItem>
|
|
</RadioGroupStacked>
|
|
</FormControl>
|
|
{form.getValues('useOrioleDb') && (
|
|
<Admonition
|
|
type="warning"
|
|
className="rounded-t-none [&>div]:text-xs"
|
|
title="OrioleDB is not production ready"
|
|
description="Postgres with OrioleDB extension is currently in Public Alpha and not recommended for production usage yet."
|
|
>
|
|
<DocsButton className="mt-2" href={`${DOCS_URL}/guides/database/orioledb`} />
|
|
</Admonition>
|
|
)}
|
|
</FormItemLayout>
|
|
</>
|
|
)}
|
|
/>
|
|
</CollapsibleCardSection>
|
|
</Panel.Content>
|
|
)
|
|
}
|