Skip to content

feat(a11y): add keyboard grid navigation to comparison table - #1529

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
mercy60:feat/issue-1363-keyboard-nav-comparison-table
Nov 24, 2026
Merged

nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
mercy60:feat/issue-1363-keyboard-nav-comparison-table

Conversation

@mercy60

@mercy60 mercy60 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1363

Rebuilds PropertyComparisonTable as an ARIA grid that is fully operable from the keyboard, and adds the other three items assigned to this contributor in the same ui-extensions/ slice: a transaction status live region (#1361), the inspection-report types (#1359), and the cross-chain bridge types (#1357) behind a new types/index.ts barrel. The most important design decision is the roving tabindex: the grid is a single tab stop, arrow keys move between cells, and focus is tracked in component state rather than derived from the DOM, so the header sort buttons stay in the normal tab order instead of being swallowed by the grid.

Also closes

Closes #1361, Closes #1359, Closes #1357

Why

PropertyComparisonTable was mouse-only. Sorting was an onClick on a plain <th>, so a keyboard user could not change the sort order at all; expanding a row was onClick on a <tr>; there was no way to move between cells; and there was no skip link, so reaching the table meant tabbing through everything above it. The table also exposed no grid semantics, so a screen reader announced the cells as unrelated table data rather than a navigable grid.

The fix follows the existing roving-tabindex guidance the issue points at and keeps the component's public API intact — ComparisonProperty, ComparisonSortKey, named and default exports, and the loading/dir props all still behave as before; the two new props are optional. No second table abstraction was introduced.

What was built

File What it contains
ui-extensions/components/PropertyComparisonTable.tsx ARIA grid (role="grid", aria-rowcount, aria-colcount), <th scope="col"> sort headers wrapping real <button>s, <th scope="row"> property names, roving tabindex over data-cell="row-column", arrow/Home/End/PageUp/PageDown navigation clamped at the edges, RTL-mirrored horizontal movement, Enter/Space to expand, Escape to collapse and refocus the row header, per-cell aria-label naming row + column + value, focus-visible outline on every cell and header button, and a skip link that is the first focusable element. Also exports the pure nextCellPosition helper.
ui-extensions/components/TransactionLiveRegion.tsx TransactionLiveRegion with a separate polite (role="status", aria-live="polite") and assertive (role="alert", aria-live="assertive") region, both aria-atomic and wrapped in sr-only. Announces pending/confirmed/failed through templates containing {hash} and {error}, debounced so only the final status in a burst is spoken. Pure helpers formatTransactionAnnouncement, shortHash, isUrgentStatus.
ui-extensions/types/inspection.ts InspectionReport, InspectionFinding, InspectorProfile, InspectionStatus, InspectionSeverity, plus InspectionCategory.
ui-extensions/types/bridge.ts BridgeTransaction, BridgeConfirmation, ValidatorSet, BridgeStatus, BridgeConfirmationStatus, BridgeChainConfig. Amounts are decimal strings so values above Number.MAX_SAFE_INTEGER are not lost.
ui-extensions/types/index.ts Barrel re-exporting every type module, including the four pre-existing ones.
ui-extensions/tests/propertyComparisonTableKeyboard.test.tsx 18 tests.
ui-extensions/tests/transactionLiveRegion.test.tsx 14 tests.
ui-extensions/tests/inspectionTypes.test.ts 5 tests.
ui-extensions/tests/bridgeTypes.test.ts 6 tests.

Integration changes outside <module>/

None — every changed path is inside ui-extensions/.

Within it, ui-extensions/components/PropertyComparisonTable.tsx is modified rather than replaced. The change is backward compatible: the exported types, the named and default exports, and the existing properties / loading / dir props are unchanged; showSkipLink and aria-label are additive and optional. ui-extensions/stories/PropertyComparisonTable.stories.tsx needed no edits and still type-checks.

The only behavioural differences consumers could notice are accessibility improvements: the sort control is now a <button> inside the header rather than a clickable <th>, and the property-name cell is a <th scope="row"> rather than a <td>. Both are required for the announced headers criterion.

Acceptance criteria coverage (primary issue)

Closes #1363 — Keyboard Navigation for Property Comparison Table

  • Tab moves between interactive elements (propertyComparisonTableKeyboard.test.tsx: moves between interactive elements with Tab — skip link → Location → Price)
  • Arrow keys navigate table cells (propertyComparisonTableKeyboard.test.tsx: navigates cells with the arrow keys; nextCellPosition moves horizontally and vertically / clamps at the edges are not crossed)
  • Enter activates sort or expand (propertyComparisonTableKeyboard.test.tsx: activates sorting with Enter on a column header; expands a row with Enter and collapses it with Escape)
  • Escape closes expanded rows (propertyComparisonTableKeyboard.test.tsx: expands a row with Enter and collapses it with Escape; leaves Escape alone when no row is expanded)
  • Focus visible indicator on all cells (propertyComparisonTableKeyboard.test.tsx: gives every cell a visible focus indicator — focus-visible:outline* on row headers, data cells and header buttons)
  • Row/column headers announced (propertyComparisonTableKeyboard.test.tsx: exposes the table as a named ARIA grid with row and column headers — scope="col" / scope="row" plus per-cell aria-label)
  • Skip-to-content link at top (propertyComparisonTableKeyboard.test.tsx: renders a skip link above the grid that moves focus into it)

Closes #1361 — Screen Reader Announcements for Transaction Updates

  • Uses aria-live='polite' for status updates (transactionLiveRegion.test.tsx: renders two visually hidden live regions with the right politeness)
  • Uses aria-live='assertive' for failures (same test; isUrgentStatus only treats failed as urgent)
  • Announces: pending, confirmed, failed (transactionLiveRegion.test.tsx: announces pending and confirmed politely; announces failures assertively and not politely)
  • Includes transaction hash in announcement (transactionLiveRegion.test.tsx: substitutes the shortened hash; shortHash keeps both ends of the hash)
  • Debounces rapid status changes (transactionLiveRegion.test.tsx: debounces rapid status changes down to the final one; honours a custom debounce window)
  • Hidden visually but accessible to SR (transactionLiveRegion.test.tsx: the wrapper is sr-only)
  • Configurable announcement messages (transactionLiveRegion.test.tsx: uses configurable announcement messages; formatTransactionAnnouncement accepts per-status message overrides)

Closes #1359 — TypeScript Types for Property Inspection Reports

  • Defines InspectionReport interface (inspectionTypes.test.ts: models a complete report with findings and inspector details)
  • Defines InspectionFinding interface (same)
  • Defines InspectorProfile interface (same)
  • Defines InspectionStatus enum (inspectionTypes.test.ts: defines the inspection status and severity enums)
  • Defines InspectionSeverity enum (same test; keeps the status and severity value sets distinct)
  • Exports all types from index file (inspectionTypes.test.ts: exports every type from the types barrel)
  • No runtime code, types only (inspectionTypes.test.ts: contains no runtime behaviour beyond the enums — the module's only runtime values are the three enums the issue requires; no functions, classes or services)

Closes #1357 — TypeScript Types for Cross-Chain Bridge Data

  • Defines BridgeTransaction interface (bridgeTypes.test.ts: models a transaction with chain config, confirmations and validator set)
  • Defines BridgeConfirmation interface (same)
  • Defines ValidatorSet interface (same)
  • Defines BridgeStatus enum (bridgeTypes.test.ts: defines the bridge and confirmation status enums; separates terminal states from in-flight states)
  • Defines BridgeChainConfig interface (bridgeTypes.test.ts: models a transaction with chain config, confirmations and validator set)
  • Exports all types from index file (bridgeTypes.test.ts: exports every type from the types barrel)
  • No runtime code, types only (bridgeTypes.test.ts: contains no runtime behaviour beyond the enums — two enums, no functions or services)

Deliberately deferred

None. All four issues assigned to this contributor are implemented in full; each Closes keyword above refers to work contained in this diff.

Test plan

  • npx jest ui-extensions/tests/{propertyComparisonTableKeyboard,transactionLiveRegion,inspectionTypes,bridgeTypes}: 43/43 passing (43 new: 18 + 14 + 5 + 6)
  • npx jest --watchAll=false --ci: 2358/2450 passing across 249 suites (before: 2315/2407 across 245 suites). The same 25 pre-existing suites / 92 pre-existing tests fail before and after; this PR adds 4 suites and 43 passing tests and no new failures.
  • npm run typecheck (tsc --noEmit): 482 errors before and 482 after — zero new, and zero errors mention ui-extensions. The story that imports the modified table still type-checks.
  • npx eslint ui-extensions: 10 errors before and 10 after — zero new. All are the pre-existing Parsing error: Unexpected token { on ui-extensions/stories/*.stories.tsx, because eslint.config.mjs only applies the TypeScript parser to src/** and .storybook/**; this PR adds no story files. See Notes.
  • npm run build: cannot pass at base. npm run build runs npm run typecheck && next build, and tsc --noEmit exits 2 on main (482 errors) while next.config.ts sets typescript.ignoreBuildErrors: false. The gate is red before this PR and this PR adds no errors to it.
  • Manual: sort the table with Tab + Enter, arrow across cells, expand a row with Enter, collapse with Escape.

Env vars / Notes

No new environment variables.

Public surface added: types/index.ts is the new barrel for ui-extensions, and PropertyComparisonTable additionally exports nextCellPosition plus the optional showSkipLink and aria-label props. No existing export was removed or renamed.

Known pre-existing gates (unchanged by this PR, documented for reviewers): typescript, lint and therefore build already fail on main because ui-extensions/** is absent from tsconfig.json's include and from the TypeScript parser files list in eslint.config.mjs. This PR does not change those configs, as the issue requires changes to stay within ui-extensions/.

The comparison table was mouse-only: sortable headers were plain <th>
click handlers, rows could not be expanded from the keyboard, and there
was no way to move between cells.

Rebuilds the table as an ARIA grid with a roving tabindex (arrows,
Home/End, RTL-aware), keyboard-activated sorting, Enter/Space expand,
Escape collapse with focus restored to the row header, and a skip link.
Also adds the other three items assigned to this contributor: a
transaction live region, and the inspection-report and cross-chain
bridge type modules behind a types barrel.
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@mercy60 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit nanaf6203-bit 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.

Reviewed and happy with this. Thanks!

@nanaf6203-bit
nanaf6203-bit merged commit aebff26 into MettaChain:main Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants