facebook / facebook/astryx

Table: expose row position to plugins (aria-rowindex) so useTableRowIndex avoids its own index map

Open
#3,940 0 comments 0 reactions 1 assignee Claimed by @humbertovirtudes View on GitHub
enhancement
Dominant language
TypeScript
Stars
13k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
690

Description

### Context

Follow-up from review of #3756 (`useTableRowIndex`).

`useTableRowIndex` currently has to build its own `item → index` map because `renderCell(item)` receives **only the row item** (no position) and runs during render — there's no row index available at derive time. The plugin works around this by taking the rendered `data` array and computing a memoized single-pass lookup.

### Proposal

If the Table exposed the row's position to plugins — e.g. via `aria-rowindex` on the `` (or a `rowIndex` passed into the cell render path) — the plugin could read it directly instead of maintaining its own map. That would:

- **Reduce the plugin's API surface** — no need to pass `data` / `getRowKey` into `useTableRowIndex` just to recover position.
- Avoid the extra bookkeeping pass entirely.
- Keep a single source of truth for row position (ties into #3939 — the ARIA row index).

### Notes

- `transformBodyCell` receives `columnIndex` but not `rowIndex` today; `transformBodyRow` gets `rowIndex` but the index column renders via `renderCell`. Exposing the row position on the cell render path (or letting the plugin read the rendered `aria-rowindex`) would close the gap.
- Pairs with #3939 (ARIA row index as a table-level concern).

_Raised from @cixzhang's review comment on #3756._

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.