Comcast / Comcast/react-data-grid

Inconsistent API for column indexes

Open
#3,906 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.7k
Forks
2.2k
Avg merge
1d 2h
Merged PRs (30d)
33

Description

## Description

There is an inconsistency in the API related to how column and row indexes are passed or returned in specific methods.
Some methods (for example: `openEditor`) provide or expect only the column/row index, rather than the original column identifier.
This causes issues when the grid’s internal state changes, such as when columns are pinned.
As a result, the indices can differ from the original ones that were passed into the grid, and it becomes impossible to determine from the outside which column index refers to.

## Issue Details
- There is **no reliable way** to map the given index back to a specific column outside the grid.
- This makes it difficult to synchronize or manage external state related to columns.

## Expected Behavior
The API should provide a **consistent way** to identify columns, regardless of internal reordering.

## Actual Behavior
When the grid updates its internal state (due to sorting, pinning, etc.), previously valid indexes no longer refer to the same columns or rows, breaking external logic that relies on them.

## Example
1. Pass data with three columns: A, B, C.
2. Pin column B.
3. Call `selectCell({idx: 2, rowIdx: 1);`
**Expected behavior:** opened 1st cell of the pinned column B
**Current behavior:** opened 1st cell of column A

## Suggested Fix
Standardize the API to use **original column indices**

> Update: https://github.com/Comcast/react-data-grid/compare/main...dbeaver:react-data-grid:add-select-cell-by-key-api - this is my suggestion to show you what can fix the situation

Could you help us solve the issue or suggest an alternative approach to nail it?

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.