Files
ChloeGarciaMillerand 8dcebc08ca fix: ESLint errors relating to accessibility in account preferences (#49301)
## 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?

Improve toggle accessibility and `aria-label` for screen readers.

## What is the current behavior?

Toggles have no accessible name or description because FormItemLayout is
not properly linked to the Switch.
An `aria-label` was missing.

## What is the new behavior?

An `aria-label` and IDs have been added to associate the label with the
switch and make the toggles accessible to screen readers.

## Additional context

No visual changes have been made.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Accessibility**
  * Improved screen reader labels for password visibility controls.
  * Linked preference labels with their corresponding toggle controls.
* Added descriptive identifiers to telemetry, dashboard, and hotkey
settings for easier navigation.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-08-24 18:05:45 +02:00

44 lines
1.6 KiB
TypeScript

import { Fragment } from 'react'
import { CardContent, KeyboardShortcut, Switch } from 'ui'
import { hotkeyToKeys } from '@/state/shortcuts/formatShortcut'
import type { ShortcutId } from '@/state/shortcuts/registry'
import { useShortcutPreferences } from '@/state/shortcuts/state'
import type { ShortcutDefinition } from '@/state/shortcuts/types'
import { useIsShortcutEnabled } from '@/state/shortcuts/useIsShortcutEnabled'
interface HotkeyToggleProps {
definition: ShortcutDefinition
isLast?: boolean
}
export function HotkeyToggle({ definition, isLast }: HotkeyToggleProps) {
const enabled = useIsShortcutEnabled(definition.id as ShortcutId)
const { setShortcutEnabled } = useShortcutPreferences()
return (
<CardContent className={isLast ? undefined : 'border-b'}>
<div className="flex items-center justify-between gap-x-3">
<label htmlFor={`id-${definition.id}`} className="text-sm text-foreground">
{definition.label}
</label>
<div className="flex items-center gap-x-3">
<div className="flex items-center gap-1">
{definition.sequence.map((step, i) => (
<Fragment key={i}>
{i > 0 && <span className="text-foreground-lighter text-[11px]">then</span>}
<KeyboardShortcut keys={hotkeyToKeys(step)} />
</Fragment>
))}
</div>
<Switch
id={`id-${definition.id}`}
checked={enabled}
onCheckedChange={(checked) => setShortcutEnabled(definition.id as ShortcutId, checked)}
/>
</div>
</div>
</CardContent>
)
}