VB Project Planning

<traceability-matrix>

Auto-discovers a 2D cross-reference grid (RTM) from page elements; composes data-table for sortable + heatmap-able presentation, adds chain highlight.

Overview

The <traceability-matrix> component renders the canonical Requirements Traceability Matrix (RTM) shape — rows × columns at-a-glance — by auto-discovering source elements on the page. Use it to verify coverage between personas and stories, stories and work items, requirements and tests, or any other cross-cutting relationship in a planning artifact graph.

It composes <data-table> so the rendered grid is sortable and styleable, and adds two things data-table can't: auto-discovery (you give it CSS selectors, not hand-built rows) and chain highlight (activating a cell marks the row and column source elements page-wide so authors can see the connection in surrounding components).

How it works

  1. Author CSS selectors for the row and column source elements (e.g. rows='[data-row-kind="story"]', cols='[data-row-kind="persona"]').
  2. Name the link attribute with link-attr. The component reads each row element's value(s) and matches them against each column element's id, story-id (<user-story>) or item-id (<work-item>). Set match-attr to match one specific attribute instead (e.g. match-attr="data-req").
  3. Comma-separated values are supported out of the box — data-persona-id="p-sarah,p-jordan" renders two checkmarks.
  4. Orphan flagging — set flag-orphans to mark empty rows and columns with data-orphan so CSS can call them out (the default style adds a ⚠ glyph).

Attributes

AttributeValuesDefaultDescription
rowsstring—CSS selector for row source elements
colsstring—CSS selector for column source elements
link-attrstring—Attribute on the row element whose value(s) reference column identifiers (see match-attr); comma-separated values supported
match-attrstring—Attribute on column elements that link-attr values are matched against. Default: the column's id, story-id (<user-story>) or item-id (<work-item>), whichever matches
labelstring—Optional heading shown above the matrix
row-labelstring—Header cell text for the row axis
cell-markstring—Glyph shown in linked cells (default: ✓)
flag-orphansboolean—Mark empty rows/columns with data-orphan for CSS targeting

Child attributes

AttributeOnValuesDescription
data-matrix-label*stringOverride the label rendered for this element in matrices that include it

Events

EventDetailDescription
traceability-matrix:ready{ rowCount, colCount, linkCount }Fired after the matrix renders
traceability-matrix:highlight{ rowEl, colEl, on }Fired when a cell toggles chain highlight (click, or Enter/Space on the cell's button)

Persona × Story example

Story × Work-item example

Pack elements work too — point at <user-story> / <work-item> directly. A work item's story-ids are matched against each story's story-id, so the stories don't need a matching id:

The matrix uses data-matrix-label on each source if present, else its id, else its trimmed text content.

Chain highlight

Each matrix cell and row header holds a <button>. Clicking it, or pressing Enter / Space while it has focus, toggles data-state-highlighted on:

  • the cell itself,
  • the matrix row,
  • the row source element page-wide,
  • the column source element page-wide.

Only one chain is highlighted at a time; rows and columns without an id highlight too. The highlight is cleared from the page when the matrix is removed. The default stylesheet adds an outline to highlighted source elements so authors can scan the page and see the connection. Listen for traceability-matrix:highlight to wire additional behaviour (auto-scroll, side panel, etc.).

Accessibility

  • Body cells keep aria-label="linked" / "not linked" and contain a button named “row × column: linked” (or “not linked”), so the relationship is spoken without relying on the ✓ glyph.
  • Buttons use aria-pressed to report the active highlight; row-header buttons are named “Highlight row”.
  • Keyboard (grid pattern). The table has role="grid" and is a single Tab stop (roving tabindex): Tab enters at the last cell you used, or the first cell. ← → ↑ ↓ move between cells, including the sortable column headers; Home / End go to the start / end of the row; Ctrl+Home / Ctrl+End to the first / last cell of the matrix. Enter or Space toggles the highlight on a cell (or sorts, on a column header). Rows hidden by filtering are skipped.
  • Why role="grid": it follows the WAI-ARIA APG grid pattern, so screen readers switch to focus mode and pass the arrow keys to the matrix instead of using them for reading. The native <tr> / <th> / <td> still map to row, column / row header, and grid cell, so headers are announced as you move. The grid is named by the label attribute (or “Traceability matrix”).

Progressive Enhancement

  1. HTML. Without JS, the matrix host is empty — auto-discovery is inherently runtime. For no-JS RTMs, render a <data-table> directly with hand-built intersection rows. The matrix component is purely additive.
  2. CSS. The :not(:defined) selector keeps the host visible pre-upgrade.
  3. JS. Auto-discovers rows/cols, builds the table, wires chain-highlight buttons, fires traceability-matrix:ready.

Related

↑