Repository navigation
test(a11y): add Table contract and bind Table - #7695
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
…the role is really removed
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression46 of 502 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thanks for the thorough contract and binding: the jsdom and Chromium checks pass on this head, but three spec-required pieces are missing before this can be approved. Please address the points below and push an update.
- Update
Table.spec.mdsoverified_byand the verification map name the new Table binding, and stop creditinguseTableSortable.test.tsxfor the descendingaria-sortstate now that its test is removed (AST-021 FR12). - Encode APG's row requirement (each row has role
rowinside the table or arowgroup), or name it in an exemption with a real owner, since neither the expectations nor the remainder reasons mention it today (AST-020 FR5). - Add an inventory exclusion for the filtering and column-resize modules, which place labelled controls inside header cells and can change the header names the contract checks (AST-021 FR4).
[Automated review]
| expect(nameHeader).toHaveAttribute('aria-sort', 'ascending'); | ||
| }); | ||
|
|
||
| it('sets aria-sort="descending" on sorted descending th', () => { |
There was a problem hiding this comment.
Removing this moves the descending aria-sort proof to the Table binding, but Table.spec.md still credits useTableSortable.test.tsx for that state in its FR5 verification row and does not list Table.a11y.test.tsx or Table.a11y.chromium.spec.ts in verified_by. AST-021 FR12 asks the migration to update both so the record names the binding.
| verifiedBy: | ||
| 'Each module’s own tests and later bindings of those modules to this contract', | ||
| reason: | ||
| 'This contract encodes the table, header, and cell roles, the table name, and sort state. Captions and descriptions, cell spans, column and row counts and indexes, detail and group rows, and header association in tables with irregular headers are not encoded here.', |
There was a problem hiding this comment.
The APG list this contract quotes also requires: “Each row container has role row and is either a DOM descendant of or owned by the table element or an element with role rowgroup.” No expectation encodes it, and neither this remainder nor the apg-interaction one (L448) names it, so it is unaccounted under AST-020 FR5. Encoding it (for example, each designated header's and cell's row computes row inside the table subtree, with violating fixtures) needs no product change, since Table renders native tr rows.
| }, | ||
| ] as const satisfies ReadonlyArray<TableA11yState>; | ||
|
|
||
| export const TABLE_A11Y_EXCLUSIONS = [ |
There was a problem hiding this comment.
useTableFiltering (a labelled filter button in the header's after slot) and useTableColumnResize (a focusable, labelled role="separator" in its overlay slot) both render inside the th, so they can change the header names table.column-headers.exposed asserts. AST-021 FR4 asks the inventory to say why such omitted states cannot change the shared outcome; one exclusion row naming those modules as owners would cover it.
…es header-cell module controls, and backlinks component:Table
There was a problem hiding this comment.
Thanks: the earlier requests are all addressed and the jsdom and Chromium lanes pass on this head, but one piece of the contract's negative proof is still missing before this can be approved. No violating fixture reaches the checks that each row, header, and cell sits inside the table, so deleting those checks leaves all 19 Chromium self-tests green, because every violating fixture already fails another check first (as the existing review comment on the fixtures notes). Please add fixtures that keep the role and name correct but move the designated row, column header, row header, and cell into a second table, list them in TABLE_MUTATIONS, and give that second table a header cell, since Chromium exposes a header-less one-row table as a layout table and the fixture would then fail on role again.
[Automated review]
| `row ${index + 1} is exposed as ${describeRole(role)}, not as a row`, | ||
| ); | ||
| } | ||
| if (!(await harness.containsSemantically(subject, row))) { |
There was a problem hiding this comment.
This row-in-table check, the header check at L131, and the cell check at L317 are not reached by any violating fixture: with all three deleted, the 19 Chromium self-tests still pass, because each fixture fails a role, name, or part-in-row check first. A fixture that keeps the part's role and name but puts it in a second table would make each of them fail only on containment. Give that second table a header cell: without one, Chromium exposes a one-row table as a layout table (LayoutTableRow, LayoutTableCell), and the fixture fails on role again.
…y violating fixtures
There was a problem hiding this comment.
This looks ready for approval: the new second-table fixtures make each of the contract's inside-the-table checks fail on containment alone, and the Chromium contract, the Table binding, and the jsdom lanes pass on this head. No code changes are needed; because Table.spec.md is a current record, the spec-owner check still needs an engineering owner's approval on this head.
[Automated review]
humbertovirtudes
left a comment
There was a problem hiding this comment.
Reviewed the updated exact head 1b8e584. The containment-only fixtures address my comment, and all 53 checks are complete with no failures. Good to go.
…ated merge # Conflicts: # .github/workflows/ci.yml # internal/a11y-spec/src/index.ts
There was a problem hiding this comment.
Thanks for the thorough contract and binding; two small fixes are needed before this can be approved. conforming-sorted (table.fixtures.ts L182–L186) and the binding's sorted-descending state (Table.a11y.renders.tsx L46) put aria-sort="descending" on Name over the rows Ada, then Grace, which is ascending order, so the only sorted positive proof for table.sort.exposed is a table whose exposed sort state contradicts its own rows; please render those rows in the order each state declares. Please also add a TABLE_A11Y_EXCLUSIONS entry for useTableRowStatus, whose generated status column adds a visually hidden header name and indicator cells that this contract checks (AST-021 FR4). After the update, the spec-owner check needs an engineering owner's approval on the new head, since Table.spec.md is a current record.
[Automated review]
| summary: | ||
| 'a table sorted by one column, with an explicit none on an unsorted header', | ||
| facts: facts({sort: SORTED}), | ||
| html: html({ariaSort: {0: 'descending', 2: 'none'}}), |
There was a problem hiding this comment.
This conforming fixture declares Name sorted descending, but ROWS (L21–L23) render Ada before Grace, which is ascending order; violating-sort-direction (L295–L298) is the fixture whose header matches these rows. Render the rows in the order this fixture declares (or declare ascending here and expose descending in the violating twin), so the sorted positive proof for table.sort.exposed is a truthful table.
| data-a11y-table | ||
| aria-label="Team members" | ||
| columns={SORTABLE_COLUMNS} | ||
| data={MEMBERS} |
There was a problem hiding this comment.
useTableSortable is headless: it sets aria-sort from the sort state but never reorders data, so this state (and the Sorted Descending story) announces “Name, sorted descending” over Ada, then Grace. Passing the members in descending name order (Grace, Ada) keeps every declared count and makes the state truthful.
| }, | ||
| ] as const satisfies ReadonlyArray<TableA11yState>; | ||
|
|
||
| export const TABLE_A11Y_EXCLUSIONS = [ |
There was a problem hiding this comment.
AST-021 FR4: useTableRowStatus prepends a generated column whose visually hidden header name and per-row indicator cells are exactly what this contract checks, and it is neither bound nor listed here. One exclusion like the selection entry (owner: the useTableRowStatus tests; this binding does not add the status column) closes it.
humbertovirtudes
left a comment
There was a problem hiding this comment.
Requesting changes on c0e6a1da7a816693904fd574241ef24ba76095f3. The improved containment-only fixtures, binding backlinks, row-role checks, and filtering/resize exclusions are credited.
-
MAJOR - the sorted positive proof is not truthful. Table.a11y.renders.tsx:36-47 declares descending Name while rendering Ada before Grace. table.fixtures.ts:182-186 has the same mismatch.
useTableSortabletransforms headers, not data. The actual source expectation passes those attributes without detecting the wrong displayed order. Render Grace before Ada in the descending positives, and derive the interactive story's rows from its sort state if it remains interactive. Keep the negative twins meaningful; no production sorting-policy change is needed. -
MINOR / completeness - row-status composition is neither bound nor excluded. Table.a11y.states.ts:90-127 omits the generated named header and cells from
useTableRowStatus. Add a narrowly scoped exclusion naming its module/tests as owner and explaining that this binding does not render the status column. Do not grow this migration into row-status remediation.
AI-assisted exact-head source review; the sort source probe ran, but Chromium/DOM binding suites were not independently rerun in this pass. Existing CI evidence and new runtime evidence must remain distinct.
…clude row status The sorted conforming fixture and the sorted-descending binding declared Name descending over rows Ada, then Grace. useTableSortable sets aria-sort but never reorders data, so the positive proof was a table whose exposed sort state contradicted its own rows. The sorted fixture and its violating twins now render Grace before Ada, and the binding's story derives its rows from the sort state. New checks fail when a sorted fixture or binding state renders rows out of the declared order. Adds the useTableRowStatus exclusion: its generated status column adds a visually hidden header name and indicator cells that this binding does not render (AST-021 FR4).
There was a problem hiding this comment.
Thanks for the update: the sorted fixture and binding state now list Grace before Ada, with self-tests that fail if that order slips, and the row-status exclusion is in place, so no further code changes are needed. The red pr-a11y job comes from a MultiSelector step on main whose spec file this branch predates, so merging main should clear it. After that, approval waits on the engineering owner who requested changes on the previous head to re-review or dismiss that request, and on an engineering owner's spec-owner approval of the component:Table evidence backlink on the new head.
[Automated review]
There was a problem hiding this comment.
This revision resolves both points from the earlier change requests: the sorted fixture and binding state now list Grace before Ada, with self-tests that fail if that order slips, the useTableRowStatus exclusion is in place, and CI, including the Table accessibility contract step, is green, so no further code changes are needed. Approval now waits on the engineering owner who requested changes on an earlier revision to re-review or dismiss that request, and on an engineering owner's spec-owner approval of the component:Table evidence backlink on this revision.
[Automated review]
…onto the base Table contract The base Table contract covers the table role and name, rows, column and row headers, and cells. `table.sort.exposed` and the sort facts move into a module contract owned beside useTableSortable, with its own positive and mutation fixtures. The Table binding composes it only for the state rendered with the sort module, through composeTablePattern, so each Table module brings its own accessibility semantics.
|
/approve-spec 8685276 |
|
/approve-spec 492fbdb |
There was a problem hiding this comment.
This revision keeps both fixes from the earlier change requests after moving sort state into its own module contract: the sorted fixture and binding state still list Grace before Ada, with self-tests that fail if that order slips, and the useTableRowStatus exclusion is still in place. The base contract and the Table binding pass in jsdom and in real Chromium, and the spec-owner approval covers this revision, so no further code changes are needed. Approval now waits on the engineering owner who requested changes on an earlier revision to re-review this revision or dismiss that request.
[Automated review]
| TABLE_MUTATIONS, | ||
| TABLE_ROW_HEADER_SELECTOR, | ||
| TABLE_ROW_SELECTOR, | ||
| TABLE_FIXTURES, |
There was a problem hiding this comment.
Nit, not blocking: TABLE_FIXTURES is no longer used in this file now that the sort fixtures live in the sort module (ESLint reports @typescript-eslint/no-unused-vars). The per-expectation describe.each(observableHere…) block below also registers no tests now, since every base expectation is accessibility-tree only and the Chromium self-test carries that proof.
Both points are addressed on the current head: the sorted fixtures render Grace before Ada with a row-order check, and the row-status exclusion keeps its owner and reason.
What this proves
Table now has an executable Table contract and a binding. A screen-reader user moving through a Table gets: a table (not a grid or plain text) with the name its caller gives it; every row exposed as a
rowinside it, holding the headers and cells shown in it; every column title exposed as acolumnheaderand every row title as arowheaderinside that table; data values exposed as ordinarycells inside it, including the default empty-state message; andaria-sorton exactly the column the rows are sorted by, with no stale direction on any other header.Test-only: no runtime, docs, or Changeset. The one record edit is the
component:Tableevidence backlink AST-021 FR12 requires (verified_byand the verification map name the new binding); it changes no behavior or decision, but becausecomponent:Tableis current it waits onspec-owner-approval.Adoption source.
spec:AST-020FR15 (current) decides the parts: Table already plays the table role, so it takes the APG Table pattern's required parts — the role, the name, the row, header, and cell roles, and the sort state. The APG Table pattern lists its keyboard interaction as "Not applicable" (a table is not a widget and its cells are not focusable), so nothing keyboard-related is adopted.component:Table's accessibility contract already records native table semantics, column-header scope, and sortaria-sortas unchanged behavior; the sort expectation cites it too.Module composition
Table accessibility is modular: each Table module brings its own accessibility semantics. The base
TABLE_PATTERNcovers only the table role and name, rows, column and row headers, and cells. Sort state is a module contract owned besideuseTableSortable(packages/core/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.ts:TABLE_SORT_MODULE,TableSortFacts,TABLE_SORTABLE_PATTERN), composed onto the base withcomposeTablePatternfrom@astryxdesign/a11y-spec. The Table binding composes it only for the state rendered with the sort module (sorted-descending); the other states bind the base alone, and a binding test fails if a state's contract and its declared modules disagree. A later module (tree or grid rows, for example) brings its semantics the same way. The sort module carries its own positive and mutation fixtures (useTableSortable.a11y.test.tsx).Expectations (AST-020 FR13)
table.role.exposedtable.name.exposedtable.rows.exposedtable.column-headers.exposedtable.row-headers.exposedtable.cells.exposedtable.sort.exposed(sort module, composed for sorted states)The row, header, and cell expectations also require each designated row, header, and cell to sit in the table's accessibility subtree, and
table.rows.exposedrequires every designated header and cell to sit in one of the designated rows, so a value rendered beside the table fails.table.name.exposedapplies when the binding declares a label; whether a caller supplies one is the caller's (2.4.6 remainder).Exemptions:
1.1.1-non-text-content→ caller content and Icon;1.3.1-info-and-relationships→ caller content and the Table modules that add rows or cells (remainder only: captions, spans, counts and indexes, detail and group rows, irregular header association);1.3.2-meaningful-sequence→ binding and caller data order;1.3.5-identify-input-purpose→ controls in cells;1.4.1-use-of-color,1.4.3-contrast-minimum,1.4.11-non-text-contrast,forced-colors→ binding and theme;2.1.1-keyboard,2.1.2-no-keyboard-trap,2.4.3-focus-order,2.4.7-focus-visible→ the Scroll region (component:Table FR1) and controls in cells;2.4.2-page-titled,3.1.1-language-of-page→ the page;2.4.4-link-purpose→ the link pattern;2.4.6-headings-and-labels→ caller labels and titles (remainder only);2.4.11-focus-not-obscured→ sticky-columns module, Scroll region, page;2.5.2-pointer-cancellation,2.5.3-label-in-name,2.5.8-target-size,3.2.2-on-input→ controls in cells;3.2.4-consistent-identification→ system and caller content;3.3.1-error-identification→ form and row-status module;3.3.2-labels-or-instructions→ form controls in cells;4.1.2-name-role-value→ the button pattern (sort control), the checkbox pattern (selection), and the row-expansion module;4.1.3-status-messages→ the status-message pattern;apg-interaction→ caller content and Table modules (remainder only: describedby captions, col/row counts and indexes, spans,aria-owns);reduced-motion→ binding and modules;at-facing-strings→ localization and caller labels, AST-009 for speech.Bindings and states
data-columnsaria-label, three column headers, first-row cellssorted-descendinguseTableSortablearia-sort="descending"on Name only, over rows in descending Name order; the unsorted sortable headers carry nonechildren-row-headers-rtldir="rtl"aria-labelledbyto a visible heading,TableHeaderCell scope="row"row headersempty-datadata={[]}useTableSortableexposes the sort state but never reordersdata, so the binding (and its story, which stays interactive) derives its rows from the sort state; a binding check fails if any sorted state renders rows out of the declared order. A sortable header computes its name from its sort button, so the binding declares those names (for exampleSort by Name, sorted descending). That is current behavior, recorded here, not changed.Known failures: none.
Not adopted here, each with its owner
aria-rowcount/aria-rowindexfor paged or windowed views): BaseTable row-index tests until a follow-up binds them.useTableSortabletests and the button pattern.useTableRowStatustests; this binding does not add the status column.useTableFilteringanduseTableColumnResizerather than here.TableScroll.a11y.chromium.spec.ts.Duplicate assertions (AST-021 FR6)
useTableSortable.test.tsx"sets aria-sort="descending" on sorted descending th" —table.sort.exposedproves the same DOM fact on the same plugin output (sorted-descending) in the jsdom lane. Mutation check: droppingaria-sortfrom the plugin fails thesorted-descendingbinding test.none, so the omission is the remaining component-specific claim.Table.test.tsxrole queries fortable/columnheader/cellare render-structure tests in jsdom; the contract proves roles only in Chromium, in the non-required pr-a11y job.Shape
internal/a11y-spec/src/patterns/table.ts— baseTABLE_PATTERN: 6 expectations with WCAG, APG Table (wording checked against the published pattern on 2026-10-19), andspec:AST-020FR15 sources; every other checklist dimension exempted with an owner.TableModuleContractandcomposeTablePatternare the module seam.packages/core/src/Table/plugins/sortable/__tests__/useTableSortable.a11y.tsand.a11y.test.tsx— the sort module contract (table.sort.exposed) and its self-test: one sorted and one unsorted conforming fixture and three violating twins; sorted fixtures render rows in the declared descending order (Grace before Ada).table.fixtures.ts— a plain HTML table in three conforming and fifteen violating forms; every base expectation has at least two violating twins, and the row, header, and cell expectations each have a twin whose part keeps its role and name but belongs to a second data table, so the in-table checks fail on containment alone. The sort fixtures moved to the sort module.table.jsdom.test.tsandtable.chromium.spec.ts— the contract self-test in both lanes.packages/core/src/Table/__tests__/Table.a11y.{states,renders,contracts,test}.ts(x)andTable.a11y.chromium.spec.ts— the four states above;contractspicks the base or the composed sortable contract per state.apps/storybook/stories/TableA11y.stories.tsx— oneno-visualstory per state, rendered from the shared renders so the lanes cannot drift..github/workflows/ci.yml— "Run Table accessibility contract" step plus its evidence upload; runs when Table, the stories, or the contract change.packages/core/src/Table/Table.spec.md—verified_bylists the two binding files and the sort module self-test; the FR5 verification row names the sort module contract the binding composes for its sorted state; the Accessibility contract row names the base contract, the sort module contract, and the existing Scroll region spec (AST-021 FR12).Evidence
15c2187(review fixes): contract jsdom self-test 17/17 and binding jsdom lane 11/11, with the new row-order checks failing 4/4 against the previous fixture and render; Table__tests__plus contract 28/28; core and a11y-spectsc, eslint, Prettier clean. Chromium evidence for this head comes from its pr-a11y run.tsc(a11y-spec), eslint, Prettier, and the repository pre-push checks clean.1b8e584: the "Run Table accessibility contract" step (pr-a11y run 39280986129) passed 28/28 — 4 conforming fixtures, all 18 violating fixtures failing their own expectation (including the four second-table fixtures, which fail on containment alone), all four Table binding states, and the every-expectation-exercised check. (An earlier head showed a labelledrole="presentation"table keeps its table role, because a global ARIA attribute overrides the presentational role, so that fixture is unlabelled.)Writing rubric results
Record touched:
component:Table(evidence backlink only).Scope