Skip to content

feat(core): Table row index as a table-level ARIA concern (#3939) - #4124

Merged
humbertovirtudes merged 1 commit into
mainfrom
feat/table-aria-rowindex
Jul 29, 2026
Merged

humbertovirtudes merged 1 commit into
mainfrom
feat/table-aria-rowindex

Conversation

@humbertovirtudes

Copy link
Copy Markdown
Contributor

What

Adds two opt-in, table-level props to Table (and BaseTable):

  • rowIndexStart — the 1-based ARIA row index of the first rendered body row.
  • rowCount — the total number of body rows across all pages/windows.

Setting either makes the table emit aria-rowindex on each body <tr> and aria-rowcount on the <table>.

Why

Follow-up from the review of #3756. startFrom on useTableRowIndex is a presentational offset for the visible # column, but the row ordinal is fundamentally an accessibility concern: aria-rowindex should be correct even when no visible index column is rendered, and it should reflect a row's position in the full dataset — not just the current page.

How

  • aria-rowindex counts data rows from rowIndexStart (default 1). A paginated/windowed view passes the offset of its first visible row, e.g. (page - 1) * pageSize + 1.
  • aria-rowcount is rowCount when known, or -1 (ARIA's "unknown count" convention) for a windowed view with an unknown total (e.g. cursor pagination).
  • The index is dataset-relative rather than DOM-relative, so it stays coherent with the visible useTableRowIndex numbering and gives intuitive "row X of Y" announcements. The header row keeps native table semantics (no ARIA row index).
  • The value is seeded as a base htmlProp before the transformBodyRow plugin pipeline, so plugins compose over it and can still override per row.

Scope / behavior change

Opt-in and backward-compatible: tables that set neither prop are byte-for-byte unchanged (no aria-rowindex/aria-rowcount emitted). This is deliberately the accessibility half of the follow-up; having the visible useTableRowIndex plugin consume this table-level index as its single source of truth is tracked separately in #3940.

Testing

  • 6 new unit tests in Table.test.tsx: default (no ARIA attrs), numbering from 1, pagination offset, unknown-count -1, header row exclusion, and plugin override. Full core suite green (123 tests).
  • 2 new Storybook stories under Core/TableRowIndex: AriaRowIndexNoVisibleColumn and AriaRowIndexWithPagination.
  • Local gates pass: build, core + docs + storybook typechecks, lint, copyright / sync-exports / token-docs checks, docsite generate + test.

Closes #3939.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 21, 2026
@vercel

vercel Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 29, 2026 6:26am

Request Review

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Table · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1938 -
Complexity N/A Very High (110) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Table - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/24 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Add `rowIndexStart` and `rowCount` props to Table. When set, the table
emits `aria-rowindex` on each body `<tr>` and `aria-rowcount` on the
`<table>`, so the row ordinal reflects a row's position in the full
dataset (correct across pagination) and is exposed to assistive tech
even when no visible index column is rendered.

- `rowIndexStart` (default 1): ARIA row index of the first rendered body
  row. For a windowed/paginated view, pass the offset of the first
  visible row, e.g. `(page - 1) * pageSize + 1`.
- `rowCount`: total dataset size for `aria-rowcount`.
- Header row keeps native semantics and is not assigned an ARIA row
  index, so visible `useTableRowIndex` numbering and `aria-rowindex`
  stay in agreement.
- Data-driven mode only; opt-in (tables that set neither prop are
  unchanged).

Closes #3939.
@humbertovirtudes
humbertovirtudes force-pushed the feat/table-aria-rowindex branch from 47e5827 to 21c18c1 Compare July 29, 2026 06:22
github-actions Bot added a commit that referenced this pull request Jul 29, 2026
@humbertovirtudes
humbertovirtudes merged commit b7d7f4b into main Jul 29, 2026
19 checks passed
@github-actions
github-actions Bot deleted the feat/table-aria-rowindex branch July 30, 2026 06:57

This branch was successfully deployed

1 active deployment
Preview — 21c18c13 Deployed Jul 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Table: expose row index / startFrom as a table-level ARIA concern (aria-rowindex)

2 participants