fix(ui): add focus-visible ring to ToggleSwitch and Sheet close (B1)

Keyboard-a11y polish to match the codebase's standard
`focus-visible:ring-[3px] focus-visible:ring-ring/40` treatment:

- ToggleSwitch (role=switch, used across every settings/config surface) had
  no focus-visible ring — keyboard users got no focus indicator.
- Sheet's close button used a bare `focus:outline-none`; now mirrors the
  Dialog close button's ring.

Slider, Button, Input, Select, Tabs, Checkbox, Switch already carry the ring.
This commit is contained in:
DrSmoothl
2026-06-16 14:10:04 +08:00
parent 636189d7c9
commit 6d4e8538ea
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ const SheetContent = React.forwardRef<React.ElementRef<typeof DialogPrimitive.Co
<DialogPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
{children}
{showClose && (
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none cursor-pointer">
<DialogPrimitive.Close className="absolute right-4 top-4 inline-flex size-7 items-center justify-center rounded-md opacity-70 transition-opacity hover:opacity-100 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40 cursor-pointer">
<X className="size-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
@@ -21,6 +21,7 @@ export function ToggleSwitch({ value, onChange, ariaLabel, disabled }: ToggleSwi
onClick={() => onChange(!value)}
className={cn(
'relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors',
'outline-none focus-visible:ring-[3px] focus-visible:ring-ring/40',
disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',
// Off-track is a neutral foreground tint so it stays visible on any
// surface — including OLED pure-black (where bg-muted vanished).