mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
## Problem `<FormItemLayout>` does not apply item id correctly. This can be seen on https://supabase.com/design-system/docs/ui-patterns/forms: open the devtool and check the form items labels. They have no `for` attribute. This makes it harder to correctly test and is an accessibility issue. Axe devtool actually report it ## Solution When inside React Hook Form, `<FormItemLayout>` actually generate an `id` (via `<FormItem>`). However, this `id` is overridden in `<FormLayout>` and read from context by `<FormLabel>`. Ensure we use the generated id unless one was provided. Also updated the paths filters for the CI check so that any changes in either `ui` or `ui-patterns` triggers the studio unit and e2e tests. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved form accessibility by ensuring labels consistently connect to their corresponding input fields. - React-based forms now correctly preserve field-specific identifiers when associating labels with inputs. - Added support for explicitly specifying a label’s input target, improving compatibility with customized form layouts. - Updated Studio forms to use consistent control identifiers and labeling behavior. - **Quality Improvements** - Automated validation now also runs when shared UI components and patterns are updated. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
94 lines
3.4 KiB
TypeScript
94 lines
3.4 KiB
TypeScript
// End of third-party imports
|
|
|
|
import { ChevronRight } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import type { UseFormReturn } from 'react-hook-form'
|
|
import {
|
|
Badge,
|
|
Collapsible,
|
|
CollapsibleContent,
|
|
CollapsibleTrigger,
|
|
FormControl,
|
|
FormField,
|
|
Switch,
|
|
} from 'ui'
|
|
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
|
|
|
|
import type { SupportFormValues } from './SupportForm.schema'
|
|
|
|
interface SupportAccessToggleProps {
|
|
form: UseFormReturn<SupportFormValues>
|
|
align?: 'left' | 'right'
|
|
className?: string
|
|
}
|
|
|
|
export function SupportAccessToggle({ form, align = 'left', className }: SupportAccessToggleProps) {
|
|
return (
|
|
<FormField
|
|
name="allowSupportAccess"
|
|
control={form.control}
|
|
render={({ field }) => {
|
|
return (
|
|
<FormItemLayout
|
|
hideMessage
|
|
className={className}
|
|
layout="flex"
|
|
align={align}
|
|
label={
|
|
<div className="flex items-center gap-x-2">
|
|
<span className="text-foreground">Allow support access to your project</span>
|
|
<Badge>Recommended</Badge>
|
|
</div>
|
|
}
|
|
description={
|
|
<div className="flex flex-col">
|
|
<span className="text-foreground-light">
|
|
Human support and AI diagnostic access.
|
|
</span>
|
|
<Collapsible className="mt-2">
|
|
<CollapsibleTrigger
|
|
className={
|
|
'group flex items-center gap-x-1 group-data-open:text-foreground hover:text-foreground transition'
|
|
}
|
|
>
|
|
<ChevronRight
|
|
size={14}
|
|
className="transition-all group-data-open:rotate-90 text-foreground-muted -ml-1"
|
|
/>
|
|
<span className="text-sm">More information</span>
|
|
</CollapsibleTrigger>
|
|
<CollapsibleContent className="text-sm text-foreground-light mt-2 space-y-2">
|
|
<p>
|
|
By enabling this, you grant permission for our support team to access your
|
|
project temporarily and, if applicable, to use AI tools to assist in
|
|
diagnosing and resolving issues. This access may involve analyzing database
|
|
configurations, query performance, and other relevant data to expedite
|
|
troubleshooting and enhance support accuracy.
|
|
</p>
|
|
<p>
|
|
We are committed to maintaining strict data privacy and security standards in
|
|
all support activities.{' '}
|
|
<Link
|
|
href="https://supabase.com/privacy"
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="text-foreground-light underline hover:text-foreground transition"
|
|
>
|
|
Privacy Policy
|
|
</Link>
|
|
</p>
|
|
</CollapsibleContent>
|
|
</Collapsible>
|
|
</div>
|
|
}
|
|
>
|
|
<FormControl>
|
|
<Switch size="large" checked={field.value} onCheckedChange={field.onChange} />
|
|
</FormControl>
|
|
</FormItemLayout>
|
|
)
|
|
}}
|
|
/>
|
|
)
|
|
}
|