mirror of
https://github.com/supabase/supabase.git
synced 2026-09-10 11:59:30 +08:00
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Improving accessibility by adding `aria-label` and associating the switches with their labels in database section. Adding `Tooltip` for icon only buttons. ## What is the current behavior? `Switch` components are not connected with their labels, `aria-label` and some `Tooltip` are missing. ## What is the new behavior? Icon-only buttons have now buttons and `aria-label` have been added. `Switch` components are connected to their labels. ## Additional context No visual changes have been made. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Accessibility Improvements** - Added descriptive labels and tooltips to database management actions, including remove, delete, and “More options” controls. - Improved screen reader support for function editor maximize/minimize controls, privilege switches, publication switches, and column actions. - Connected privilege labels with their corresponding controls for clearer navigation. - Clarified permission-related messaging when deleting columns. - Reduced duplicate announcements from tooltips and accessible descriptions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Gildas Garcia <1122076+djhi@users.noreply.github.com>
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { Maximize2, Minimize2 } from 'lucide-react'
|
|
import { Button, cn, FormControl, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
import { CodeEditor } from '@/components/ui/CodeEditor/CodeEditor'
|
|
|
|
export const FunctionEditor = ({
|
|
field,
|
|
language,
|
|
focused,
|
|
setFocused,
|
|
}: {
|
|
field: any
|
|
language: string
|
|
focused: boolean
|
|
setFocused: (b: boolean) => void
|
|
}) => {
|
|
return (
|
|
<div className={cn('rounded-md relative group grow')}>
|
|
<FormControl>
|
|
{language !== undefined && (
|
|
<CodeEditor
|
|
id="database-functions-editor"
|
|
language="pgsql"
|
|
placeholder={language === 'plpgsql' ? `BEGIN\n\nEND;` : undefined}
|
|
value={field.value}
|
|
onInputChange={field.onChange}
|
|
/>
|
|
)}
|
|
</FormControl>
|
|
<div
|
|
className={cn(
|
|
'absolute top-0 right-2 bg-surface-300 border border-strong rounded-sm h-[28px]',
|
|
'opacity-0 group-hover:opacity-100 group-hover:top-2 transition-all'
|
|
)}
|
|
>
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Button
|
|
variant="text"
|
|
size="tiny"
|
|
className={cn(
|
|
'px-1.5 text-foreground-lighter hover:text-foreground',
|
|
'transition z-50'
|
|
)}
|
|
onClick={() => setFocused(!focused)}
|
|
icon={focused ? <Minimize2 /> : <Maximize2 />}
|
|
aria-label={focused ? 'Minimize editor' : 'Maximize editor'}
|
|
// Tooltip repeats the label; the description would read the name twice
|
|
aria-describedby={undefined}
|
|
/>
|
|
</TooltipTrigger>
|
|
<TooltipContent side="bottom">
|
|
{focused ? 'Minimize editor' : 'Maximize editor'}
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|