mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 18:11:51 +08:00
## What kind of change does this PR introduce? Accessibility / lint hardening (Safari keyboard focus). ## What is the current behavior? `supabase/require-explicit-tabindex` is `'warn'`. Studio’s ratchet was at 0 but the rule was still ratcheted; www / docs / design-system still had raw `<button>` / `role="button"` call sites without an explicit `tabIndex`. [DEPR-627](https://linear.app/supabase/issue/DEPR-627) · follow-up to #47984 / #48040 ## What is the new behavior? - Shared config: `'supabase/require-explicit-tabindex': 'error'` - Swept www / docs / design-system (+ Studio test fixtures the ratchet skipped) - Removed the rule from the Studio ratchet + baselines ## To test Prefer **Safari**. This PR only adds explicit `tabIndex` to raw `<button>` / `role="button"` call sites — not links, and not controls that already go through `Button` from `ui`. ### Marketing (`www`) ([staging link](https://zone-www-dot-com-git-danny-depr-627-promote-req-7ae43c-supabase.vercel.app/)) - [x] Homepage frameworks / dashboard feature tabs — Tab through each tab button - [x] Product pages (e.g. `/auth`, `/database`) — section tab switchers - [x] Narrow viewport — open the hamburger; Tab through menu buttons - [x] `/partners/catalog` — filter / view controls - [x] Blog view toggle (list ↔ grid) ### Docs ([staging link](https://docs-git-danny-depr-627-promote-require-explici-25e46d-supabase.vercel.app/)) - [x] **Desktop (≥ lg):** top-right **⋯ menu** (hamburger icon) — opens a dropdown that includes Theme. Not a separate theme button. - [x] **Mobile (< lg):** top-right **hamburger** opens the sheet; close (X) is the raw button we tagged. Theme inside the sheet uses `ThemeToggle` / `DropdownMenuTrigger` from `ui` (already supposed to set `tabIndex`). - [x] **Code blocks** — copy / language controls - [x] **Is this helpful?** — X / check are `Button` from `ui` (should already Tab). After voting **while signed in**, the follow-up “What went well?” / “How can we improve?” text button is the raw one we tagged. - [x] **AI Tools → Copy as Markdown** (right rail on a guide) — this is the only GuidesSidebar control this PR changed. “On this page” TOC items are **links**, not covered by this lint. - [x] **Reference docs** (e.g. JS client reference) — section headers that expand/collapse in the left nav (`Collapsible.Trigger`) - [x] **Troubleshooting index** — type in the search field, then Tab to the **clear (X)** control ### Dashboard (`studio`) No production UI changes in this PR (tests + lint config only). Quick Safari smoke that prior tabindex work still holds: - [x] Project sidebar — Tab through primary nav links - [x] Settings → General — Tab through inputs / buttons - [x] Storage → Files — Tab a bucket row / file actions
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
import { XCircle } from 'lucide-react'
|
|
import { FC, PropsWithChildren, useState } from 'react'
|
|
import { Badge } from 'ui'
|
|
|
|
interface IOptions {
|
|
name?: string
|
|
}
|
|
|
|
type IOption = any
|
|
|
|
type OptionsSubComponents = {
|
|
Option: IOption
|
|
}
|
|
|
|
const Options: FC<PropsWithChildren<IOptions>> & OptionsSubComponents = (props) => {
|
|
const [open, setOpen] = useState(false)
|
|
return (
|
|
<div className="mt-0">
|
|
<button
|
|
tabIndex={0}
|
|
className={[
|
|
'px-5 py-1',
|
|
'border-t border-l border-r border-default',
|
|
'text-left text-sm text-foreground-light',
|
|
'hover:bg-surface-100',
|
|
'flex items-center gap-2',
|
|
open ? 'w-full rounded-tl-lg rounded-tr-lg' : 'border-b rounded-full',
|
|
].join(' ')}
|
|
onClick={() => setOpen(!open)}
|
|
>
|
|
<div>
|
|
<div className={[!open ? 'rotate-45' : 'rotate-0'].join(' ')}>
|
|
<XCircle size={14} />
|
|
</div>
|
|
</div>
|
|
{`${!open ? `Open` : `Close`} ${props.name ?? 'accepted values'}`}
|
|
</button>
|
|
<div className={['opacity-0', open ? 'opacity-100 h-auto' : 'invisible h-0'].join(' ')}>
|
|
{props.children}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const Option: FC<IOption> = (props) => {
|
|
return (
|
|
<div
|
|
className="
|
|
px-5 py-3 first:border-t border-b border-l border-r
|
|
border-default
|
|
last:rounded-bl-lg last:rounded-br-lg
|
|
flex flex-col gap-3
|
|
"
|
|
>
|
|
<div className="flex flex-wrap gap-3 items-center">
|
|
<span className="text-sm text-foreground font-mono font-medium">
|
|
{props.name ?? 'no-name'}
|
|
</span>
|
|
{!props.isEnum && (
|
|
<>
|
|
{props.isOptional ? (
|
|
<Badge variant="default">Optional</Badge>
|
|
) : (
|
|
<Badge variant="warning">Required</Badge>
|
|
)}
|
|
<span className="text-foreground-muted text-xs">{props.type ?? 'no type'}</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
|
|
{props.description && (
|
|
<p className="text-sm text-foreground-lighter m-0">{props.description}</p>
|
|
)}
|
|
|
|
{props.children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
Options.Option = Option
|
|
|
|
export default Options
|