feat(core): add useTableRowIndex plugin#3756
Merged
humbertovirtudes merged 2 commits intoJul 14, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
reviewed
Jul 11, 2026
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
July 12, 2026 03:26
Prepends a right-aligned, monospaced row-number column to the table. - Numbering follows the rendered `data` order, so it reflects the current sort / filter / pagination view (consumer passes the sorted/paged array). - `getRowKey` for stable keyed lookup across new object identities; `label` and `startFrom` customize the header and starting ordinal. - Storybook stories (default, custom label/start, renumber-with-sort), docsite hook doc + example block, unit tests, and Table Lab toggle.
Address review feedback (cixzhang) and self-review findings: - Collapse the dual Map (indexByKey + indexByRef) into a single-pass memoized lookup closure, resolving the "two loops" comment and the KISS/readability concern. One Map, built once per [data, getRowKey]. - Stabilize plugin identity: the returned plugin now depends only on the memoized lookup + presentational props, not on data directly, so it is as stable as its inputs allow (addresses "unstable on data updates"). - Document that getRowKey must return a UNIQUE string per row (duplicate keys collapse to one ordinal) and recommend useCallback for stability; updated doc.mjs wording "stable" -> "unique". - Tests: add renumber-on-reorder (reference + keyed paths), keyed-vs- fresh-identity, single-row, and empty-data cases. The keyed reorder test fails for the right reason if the keyed branch regresses. 9/9 green. Tags: ai-generated This diff was generated with AI assistance (Navi). The refactor and tests were produced by an AI agent; the human author reviewed and approved the changes.
humbertovirtudes
force-pushed
the
navi/feat/table-row-index
branch
from
July 14, 2026 18:05
073d137 to
e052c4d
Compare
Contributor
PR Analysis ReportNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | View full report |
humbertovirtudes
marked this pull request as ready for review
July 14, 2026 19:51
humbertovirtudes
requested review from
ejhammond and
imdreamrunner
as code owners
July 14, 2026 19:51
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
useTableRowIndex— a plugin that prepends a right-aligned, monospaced row-number column.Design
dataorder, so it reflects the current sort / filter / pagination view. Pass the same array you hand to<Table data>(post sort/page).renderCellreceives only the row item (not its index), so the plugin takes thedataarray and derives each ordinal — bygetRowKeywhen provided (stable across new object identities), otherwise by reference.label(default#) andstartFrom(default1) customize the header and starting ordinal.align: 'end',resizable: false; number renders in the code font withtabular-numsand secondary text color.Includes
Core/TableRowIndex):Default,CustomLabelAndStart,RenumbersWithSort(numbers re-derive as the sort order changes).useTableRowIndexhook page + a "Numbered Rows" example block.startFrom, custom label, keyed lookup in data order.Validation