Skip to content

DataTable: Add controllable row group expansion - #8533

Open
rickyzhangca wants to merge 10 commits into
mainfrom
rickyzhangca-datatable-group-expansion
Open

rickyzhangca wants to merge 10 commits into
mainfrom
rickyzhangca-datatable-group-expansion

Conversation

@rickyzhangca

@rickyzhangca rickyzhangca commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/github/primer/issues/6721

Adds opt-in group expansion to DataTable and Table.Group. Builds on the row selection merged in #8415 and targets main; bulk actions remains an independent sibling PR.

Collapsing only changes visibility. Members stay mounted and remain in the selection model, so current-page select-all includes collapsed selectable rows. A controlled collapse restores focus to the disclosure only when it hides the focused member.

CleanShot.2026-10-14.at.5.09.31.PM.mp4

Changelog

New

  • DataTable: collapsibleGroups, expandedGroups, defaultExpandedGroups, onExpandedGroupsChange({expandedGroups}). Expansion sets use stable string/number group IDs.
  • Table.Group: collapsible, expanded, defaultExpanded, onExpandedChange({expanded}).
  • Config and presentational examples, API documentation, regression tests, and light/dark Linux snapshots.

Changed

Group keys distinguish string and numeric IDs. Non-collapsible groups remain expanded. Uncontrolled expansion defaults to the groups in the initial data; new IDs start collapsed, and stored IDs survive data replacement.

Removed

None.

Rollout strategy

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Opt-in experimental API addition. Review/merge bulk actions before expansion; neither follow-up changes the other's implementation.

Testing & Reviewing

  • VITEST_FAIL_ON_CONSOLE=true npm test -- --run: passed, 2744 tests with React 18.3.1, including browser-rendered SSR and hydration without warning suppression.
  • VITEST_FAIL_ON_CONSOLE=true npm test -- --run packages/react/src/DataTable/__tests__: passed, 206 tests covering state, selection compatibility, focus, hydration, and disclosure size with long labels. Alignment assertions cover all three densities, LTR/RTL, and expanded/collapsed states.
  • npm run build, npm run type-check: passed.
  • npm run lint, npm run lint:css, npm run format:diff, npm run test:classname-coverage: passed.
  • npx markdownlint-cli2 packages/react/src/DataTable/DataTable.accessibility.md: passed.
  • npm run format, npm run lint:fix: passed before committing.
  • STORYBOOK_URL=http://localhost:6008 npx playwright test e2e/components/DataTable.test.ts --grep 'group expansion hides' --workers=1: passed; verifies keyboard activation, controlled-collapse focus recovery, hidden Tab order, selection compatibility, and axe.
  • Four Linux baselines were refreshed after correcting disclosure/checkbox center alignment and label spacing: generation and automatic commit passed. Latest-commit CI/VRT is tracked by the PR checks.

Manual review still needed: verify NVDA/JAWS/VoiceOver disclosure name, count, expanded state, and table navigation across collapsed groups. Automated checks do not replace assistive-technology review. Count descriptions currently use English. The implementation uses Primer's existing button/state primitives, not @github-ui/disclosure.

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cc1abbf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rickyzhangca rickyzhangca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 13, 2026
@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@primer

primer Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 13, 2026 18:15 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 13, 2026
@github-actions
github-actions Bot requested a deployment to storybook-preview-8533 October 13, 2026 18:22 Abandoned
@primer

primer Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🤖 Lint issues have been automatically fixed and committed to this PR.

@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 13, 2026 18:31 Inactive
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 13, 2026 19:12 Inactive
@rickyzhangca rickyzhangca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 13, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 13, 2026 19:34 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 13, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 13, 2026 19:45 Inactive
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 14, 2026 01:56 Inactive
Base automatically changed from agents/implement-row-selection-datatable to main October 14, 2026 16:06
@rickyzhangca
rickyzhangca requested a balanced review from Copilot October 14, 2026 18:36

Copilot AI 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.

🟡 Changes recommended

Callback refs break mixed-state selection, and manual screen-reader validation remains outstanding.

1 open finding
What changed in this PR

Adds opt-in group expansion to experimental DataTable and Table.Group, building on current-page row selection.

Changes:

  • Adds controlled and uncontrolled expansion with stable group IDs.
  • Keeps collapsed rows mounted and selectable, with focus recovery.
  • Adds documentation, examples, and regression coverage.
File Description
packages/​react/​src/​experimental/​index.ts Exports selection types.
packages/​react/​src/​DataTable/​useTable.ts Manages selection and expansion state.
packages/​react/​src/​DataTable/​TableGroup.tsx Adds disclosure controls and focus recovery.
packages/​react/​src/​DataTable/​Table.tsx Adds composable selection controls.
packages/​react/​src/​DataTable/​Table.module.css Styles disclosures and hidden groups.
packages/​react/​src/​DataTable/​Table.features.stories.tsx Demonstrates presentational APIs.
packages/​react/​src/​DataTable/​row.ts Defines shared row ID type.
packages/​react/​src/​DataTable/​index.ts Exposes selection components and types.
packages/​react/​src/​DataTable/​DataTable.types.test.tsx Checks public API types.
packages/​react/​src/​DataTable/​DataTable.tsx Integrates selection and expansion.
packages/​react/​src/​DataTable/​DataTable.features.stories.tsx Adds interactive examples.
packages/​react/​src/​DataTable/​DataTable.docs.json Documents new APIs.
packages/​react/​src/​DataTable/​DataTable.accessibility.md Explains accessibility contracts.
packages/​react/​src/​DataTable/​__tests__/​DataTableSelection.test.tsx Tests selection behavior.
packages/​react/​src/​DataTable/​__tests__/​DataTableGrouping.test.tsx Updates typed group-key expectations.
packages/​react/​src/​DataTable/​__tests__/​DataTableExpansion.test.tsx Tests expansion, focus, and hydration.
packages/​react/​src/​__tests__/​__snapshots__/​exports.test.ts.snap Records added exports.
e2e/​components/​Table.test.ts Covers composed selection interactions.
e2e/​components/​DataTable.test.ts Covers expansion and selection scenarios.
.changeset/​selectable-data-table-rows.md Records selection release addition.
.changeset/​datatable-group-expansion.md Records expansion release addition.

🧠 Review effort: Balanced


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

Comment thread packages/react/src/DataTable/Table.tsx Outdated
rickyzhangca and others added 4 commits October 14, 2026 15:31
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Recover focus at commit time without layout effects, preserve disclosure target size under long labels, and tighten expansion documentation and regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
rickyzhangca and others added 3 commits October 14, 2026 15:31
Center the 24px disclosure target over the checkbox slot and derive text spacing from cell density. Cover alignment in both directions and expansion states.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Replace the arbitrary Tab loop with explicit focus destinations and retain dedicated state, selection, hydration, sizing, and alignment coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@rickyzhangca rickyzhangca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 14, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8533 October 14, 2026 20:15 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 14, 2026
@rickyzhangca rickyzhangca added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 14, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Oct 14, 2026
Restore unrelated AvatarStack image churn from the snapshot workflow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  Changes   Passed
Passed  CI   Passed
Passed  VRT   Passed
Passed  Projects   Passed

All checks passed!

@github-actions github-actions Bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 14, 2026
@llastflowers
llastflowers requested a balanced review from Copilot October 15, 2026 16:39

Copilot AI 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.

🔵 Needs a closer look

Manual NVDA, JAWS, and VoiceOver validation remains outstanding for disclosure announcements and navigation across collapsed groups.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

This branch was successfully deployed

2 active deployments
storybook-preview-8533 — cc1abbf5 Deployed Oct 14, 2026 by github-actions[bot]
github-pages — cc1abbf5 Deployed Oct 14, 2026 by rickyzhangca via deploy-preview #33706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants