Skip to content

feat(table): add indexBy prop for ID-based expansion tracking#678

Open
platex-rehor-bot wants to merge 1 commit into
patternfly:mainfrom
platex-rehor-bot:bot/RHCLOUD-48835
Open

feat(table): add indexBy prop for ID-based expansion tracking#678
platex-rehor-bot wants to merge 1 commit into
patternfly:mainfrom
platex-rehor-bot:bot/RHCLOUD-48835

Conversation

@platex-rehor-bot

Copy link
Copy Markdown

Summary

Adds an optional indexBy prop to DataViewTableBasic and DataViewTableTree components. When provided, expanded row state is tracked by a stable data property (e.g., id) instead of the array index, so expansion follows the correct row through sorting, filtering, and pagination.

Closes #677

RHCLOUD-48835

Changes

  • DataViewTableBasic: Added indexBy prop. When set, expansion state (expandedRowsState, expandedColumnIndex) is keyed by the resolved row property instead of rowIndex. ExpandableContent.rowId type widened to string | number.
  • DataViewTableTree: Added indexBy prop. When set, getNodeId() resolves node identity from the specified property instead of the default id field.
  • DataViewTable: indexBy prop passes through to both basic and tree variants via their existing prop interfaces.
  • Backward compatible — omitting indexBy preserves current index-based behavior.

Usage

<DataViewTable
  indexBy="id"
  rows={rows.map(repo => ({ row: [...], id: repo.id }))}
  isExpandable
  expandedRows={[{ rowId: "repo-1", columnId: 1, content: <Details /> }]}
/>

Test plan

  • Existing 10 tests pass unchanged (5 basic + 5 tree)
  • 3 new DataViewTableBasic tests: render with indexBy, expandable with indexBy uses row ID, default behavior preserved
  • 2 new DataViewTableTree tests: render with indexBy, expandAll with indexBy
  • ESLint: 0 errors (only pre-existing warnings)

🤖 Generated with Claude Code

RHCLOUD-48835
Support tracking expanded rows by a data property instead of array
index. When indexBy is provided, expansion state follows the correct
row through sort, filter, and pagination operations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Basic Table: Support ID-based tracking for row expansion

1 participant