Skip to content

Fix AbstractRow rowheaders/columnheaders no-op concat - #671

Merged
fpigeonjr merged 2 commits into
masterfrom
gh-658-abstractrow-never-populates-rowheaders-columnheade
Sep 1, 2026
Merged

Fix AbstractRow rowheaders/columnheaders no-op concat#671
fpigeonjr merged 2 commits into
masterfrom
gh-658-abstractrow-never-populates-rowheaders-columnheade

Conversation

@fpigeonjr

Copy link
Copy Markdown
Contributor

Description

AbstractRow._setRowHeaders called Array.prototype.concat on this.rowheaders / this.columnheaders without assigning the result back. concat returns a new array rather than mutating in place, so the return value was silently discarded and the public rowheaders/columnheaders properties on AbstractRow were always empty — regardless of the row's actual DOM content. Only the flattened cells collection reflected reality.

Fixed by assigning the concat result back:

this.rowheaders = this.rowheaders.concat(cells);
this.columnheaders = this.columnheaders.concat(cells);

Added a Vitest spec (abstract-row.spec.ts) asserting rowheaders/columnheaders are populated with the correct cells (and only those cells) after construction.

No Playwright/E2E coverage added: this is pure array-mutation logic with no CSS cascade, layout, or pointer hit-testing dependency, so per AGENTS.md's Vitest/Playwright testing-boundary guidance it's fully and more cheaply verified in jsdom.

Motivation and Context

Flagged by Copilot review on PR #654 (#654 (comment)). Left out of that PR since it was a spec-only PR and this is a pre-existing implementation bug.

Closes #658

Type of Change (Select One and Apply Label)

  • Bug fix (non-breaking change which fixes an issue) → Apply bugfix label
  • New feature (non-breaking change which adds functionality) → Apply enhancement label
  • Breaking change (fix or feature that would cause existing functionality to change) → Apply breaking label
  • Documentation / configuration update → Apply maintenance label

How to Test

  1. npm ci && npm ci --prefix test-app
  2. cd test-app && npx vitest run --config vitest.config.mts -t "AbstractRow" — confirms the new spec passes and the header collections are populated
  3. npm --prefix test-app test — confirms the full suite still passes (151 files / 1378 tests)

Expected result: AbstractRow.rowheaders contains only cells with role="rowheader", and AbstractRow.columnheaders contains only cells with role="columnheader", matching the row's actual DOM content.

Screenshots (if appropriate)

N/A — internal logic fix, no UI changes.

Checklist

  • Branch name follows convention (e.g. gh-<number>-<slug>)
  • PR title starts with a verb in the imperative mood
  • I have self-reviewed my own code
  • format:check passes (npm run format:check)
  • lint passes (npm run lint)
  • build passes (cd test-app && npm run build)
  • Tests pass and coverage is reported (cd test-app && npm test)
  • If this change requires a documentation update, I have updated it accordingly
  • If there are dependent changes, they have been merged and published in downstream modules

Note: npm run coverage:check currently fails on master at the tip commit (db5cc25b) with these exact percentages — confirmed via gh run view on master's own CI run. This PR's change is coverage-neutral to slightly positive; the pre-existing floor miss is unrelated and out of scope here.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes AbstractRow header collections so they reflect discovered DOM cells.

Changes:

  • Assigns concatenated header cells back to their collections.
  • Adds Vitest coverage for row and column headers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
abstract-row.ts Populates header collections.
abstract-row.spec.ts Verifies header classification.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/ui-kit/experimental/aria/abstract-grid/abstract-row.ts
fpigeonjr added a commit that referenced this pull request Sep 1, 2026
_findCells called _getCellsByRole twice per role — once to build the
header collections via _setRowHeaders, and again to build the
accumulator returned as cells. Each call constructs new AbstractCell
instances, which also register duplicate keydown/click listeners on
every header DOM node. Reuse the already-created cells value in the
reducer so rowheaders/columnheaders are true subsets of cells and each
node is initialized exactly once.

Addresses Copilot review comment on PR #671.
_setRowHeaders discarded the result of Array.prototype.concat instead
of assigning it, so the public rowheaders/columnheaders collections on
AbstractRow were always empty regardless of the row's actual DOM
content. Assign the concat result back to the properties, and add a
spec asserting the header collections are populated correctly.

Fixes #658
_findCells called _getCellsByRole twice per role — once to build the
header collections via _setRowHeaders, and again to build the
accumulator returned as cells. Each call constructs new AbstractCell
instances, which also register duplicate keydown/click listeners on
every header DOM node. Reuse the already-created cells value in the
reducer so rowheaders/columnheaders are true subsets of cells and each
node is initialized exactly once.

Addresses Copilot review comment on PR #671.
@fpigeonjr
fpigeonjr force-pushed the gh-658-abstractrow-never-populates-rowheaders-columnheade branch from f88df5d to a4b75b2 Compare September 1, 2026 18:30
@fpigeonjr
fpigeonjr marked this pull request as ready for review September 1, 2026 18:37
@fpigeonjr
fpigeonjr requested a review from a team as a code owner September 1, 2026 18:37
@fpigeonjr
fpigeonjr merged commit 78f8677 into master Sep 1, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AbstractRow never populates rowheaders/columnheaders (no-op concat)

3 participants