Skip to content

fix(studio): keyboard focus on button - #40458

Merged
dnywh merged 14 commits into
masterfrom
dnywh/fix/button-tab-index
Nov 25, 2025
Merged

dnywh merged 14 commits into
masterfrom
dnywh/fix/button-tab-index

Conversation

@dnywh

@dnywh dnywh commented Nov 14, 2025 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

  • Fix

What is the current behavior?

  • Button component doesn’t have keyboard focus support out of the box (for Safari)

What is the new behavior?

  • Button component now supports keyboard focus on Safari via tabIndex
  • Sidebar items similarly now support keyboard focus on Safari via tabIndex
  • Expanded accessibility documentation in Design System

Additional context

@dnywh
dnywh requested review from a team as code owners November 14, 2025 05:33
@vercel

vercel Bot commented Nov 14, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
cms Ready Ready Preview Comment Nov 25, 2025 11:38pm
design-system Ready Ready Preview Comment Nov 25, 2025 11:38pm
docs Ready Ready Preview Comment Nov 25, 2025 11:38pm
studio-self-hosted Ready Ready Preview Comment Nov 25, 2025 11:38pm
studio-staging Ready Ready Preview Comment Nov 25, 2025 11:38pm
ui-library Ready Ready Preview Comment Nov 25, 2025 11:38pm
zone-www-dot-com Ready Ready Preview Comment Nov 25, 2025 11:38pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
studio Ignored Ignored Nov 25, 2025 11:38pm

@supabase

supabase Bot commented Nov 14, 2025

Copy link
Copy Markdown

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

className={buttonClassName}
icon={<Plus size={14} />}
disabled={isDisabled}
tabIndex={isDisabled ? -1 : 0}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now handled in the underlying Button component, which (by default) sets the tabIndex in the same way; based on the disabled state.

/>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button tabIndex={0} type="default" icon={<ArrowDownNarrowWide />}>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant given it’s now in the component itself.

Comment on lines 248 to +253

// Set default tabIndex for proper Safari focus handling
// - Explicit tabIndex prop takes precedence
// - If disabled, default to -1 (unless explicitly set)
// - Otherwise, default to 0 for keyboard accessibility
const computedTabIndex = tabIndex !== undefined ? tabIndex : disabled ? -1 : 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it says on the can!

Comment on lines +556 to +562
const { disabled, tabIndex } = props

// Set default tabIndex for proper Safari focus handling
// - Explicit tabIndex prop takes precedence
// - If disabled, default to -1 (unless explicitly set)
// - Otherwise, default to 0 for keyboard accessibility
const computedTabIndex = tabIndex !== undefined ? tabIndex : disabled ? -1 : 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like Button, the sidebar items weren’t navigable by keyboard on Safari.

@github-actions

Copy link
Copy Markdown
Contributor

Studio E2E Results

  • Total: 1
  • Passed: 1
  • Failed: 0
  • Skipped: 0
  • Timed out: 0
  • Interrupted: 0
  • Flaky: 0
  • Duration: 2.1s

Artifacts: https://github.com/supabase/supabase/actions/runs/19355388770

Last updated: Friday 14, November, 2025 05:46:28 (UTC)

@awaseem awaseem left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is such a nice change, TY

@awaseem

awaseem commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Just some minor merge conflicts to fix @dnywh

# Conflicts:
#	apps/studio/components/interfaces/Storage/FilesBuckets/index.tsx
@github-actions

github-actions Bot commented Nov 17, 2025 •

Copy link
Copy Markdown
Contributor

🎭 Playwright Test Results

passed  50 passed
flaky  5 flaky

Details

stats  55 tests across 8 suites
duration  9 minutes, 25 seconds
commit  832720b

Flaky tests

Features › database.spec.ts › Database › Schema Visualizer › actions works as expected
Features › database.spec.ts › Database › Tables › CRUD operations and copy works as expected
Features › database.spec.ts › Database › Tables columns › can view, create, update, delete, and filter table columns
Features › rls-policies.spec.ts › RLS Policies › Create RLS Policy › should create an INSERT policy with authenticated role
Features › rls-policies.spec.ts › RLS Policies › Create RLS Policy › should create an UPDATE policy with custom condition

@coveralls

coveralls commented Nov 18, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 68.855%. remained the same
when pulling 7674a8a on dnywh/fix/button-tab-index
into ba16b2c on master.

@kemaldotearth kemaldotearth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mr. Safari :shipit:

# Conflicts:
#	apps/design-system/content/docs/accessibility.mdx
@dnywh
dnywh enabled auto-merge (squash) November 25, 2025 23:35
@dnywh
dnywh merged commit 74fa49d into master Nov 25, 2025
@dnywh
dnywh deleted the dnywh/fix/button-tab-index branch November 25, 2025 23:48
dnywh added a commit that referenced this pull request Jul 17, 2026
## What kind of change does this PR introduce?

A11y fix for keyboard focus (esp. Safari), plus a lint rule to keep it
from regressing.

## What is the current behavior?

`Button` already defaults an explicit `tabIndex={0}` (#40458). Other
interactive primitives (Checkbox, bare triggers, etc.) still skip Tab
focus in Safari unless macOS Keyboard navigation is on. Raw `<button>`
call sites have no guardrail.

## What is the new behavior?

- Same explicit `tabIndex` default baked into Checkbox, Accordion
Trigger, Collapsible Trigger, Dropdown Menu / Popover / Dialog / Sheet /
Alert Dialog triggers, Table Head Sort, Command reset, sidebar actions,
and shadcn Button
- `supabase/require-explicit-tabindex` ESLint rule, ratcheted in Studio
(82 existing violations)
- Design-system accessibility docs list which primitives bake this in

Resolves [DEPR-621](https://linear.app/supabase/issue/DEPR-621)

## Additional context

### To test

Use **Safari** with macOS Keyboard navigation **off** (the default).
Chrome once for a sanity pass.

**Storage → Files bucket (list view) — Checkbox**

1. Open an empty folder (or one with only folders). Header “select all”
Checkbox is disabled and skipped by Tab — expected (`columnFiles.length
=== 0`).
2. Upload a file (e.g. an image). Header Checkbox enables.
3. Tab to it and toggle with Space. Row Checkboxes should also be
Tab-reachable.

**Storage → Analytics bucket → bucket details — Accordion Trigger**

On an Analytics bucket with no tables yet, Tab to the “Create your first
table via PyIceberg” Accordion Triggers and open/close with Enter/Space.

**Elsewhere (light smoke)**

- Bare Dropdown / Popover / Collapsible triggers still Tab + activate
- `*Trigger asChild><Button>` (Sheets, Dialogs, menus) still one Tab
stop; open/close fine
- Disabled controls stay out of the Tab order

### Later

Chip-away of the 82 raw Studio buttons (and remove exceptions from
rule). Prefer migrating those to `Button` from `ui` later.

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

* **Accessibility Improvements**
* Improved keyboard focus behavior across common interactive controls
(buttons, dialog/popover/dropdown/sheet triggers,
accordions/collapsibles, checkboxes, and sidebar actions).
* Disabled controls now default to `tabIndex={-1}`, while enabled
controls default to `tabIndex={0}`.
* Added explicit `tabIndex` handling for command reset and table sort
header controls.
* **New Features**
* Added a shared `getExplicitTabIndex` utility used by UI components to
standardize focus behavior.
* **Documentation**
* Updated accessibility guidance to clarify which components include
built-in focus/tabIndex handling and which require manual setup.
* **Developer Experience**
* Added an ESLint rule to enforce explicit `tabIndex` on raw button-like
elements, with corresponding baseline updates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants