You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rows and Cells don't have a stable keys if the row is move to another index #1459
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
Terms
I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
In React, keys should represent the identity of the underlying data, not its position in the array. Currently, the row and cell keys include row.index / staticRowIndex. This causes React to treat a row as a different element whenever its order changes, even though it’s still the same underlying row.
That leads to issues like:
DOM nodes being torn down and recreated when rows are reordered.
Input fields losing focus (as shown in the demo).
Any stateful components inside the row/cell resetting unnecessarily.
By instead using only a stable row identifier (e.g., row.id, which can come from getRowId), React can correctly preserve the existing DOM nodes when rows move, keeping input focus and local state intact.
So it’s not just “removing info” from the key, but making sure the key reflects the row’s identity rather than its position.
Activity
fix: rows and cells don't have a stable keys if the row is move to an…
Mathieu-COSYNS commentedon Oct 1, 2025
In React, keys should represent the identity of the underlying data, not its position in the array. Currently, the row and cell keys include
row.index/staticRowIndex. This causes React to treat a row as a different element whenever its order changes, even though it’s still the same underlying row.That leads to issues like:
By instead using only a stable row identifier (e.g.,
row.id, which can come fromgetRowId), React can correctly preserve the existing DOM nodes when rows move, keeping input focus and local state intact.So it’s not just “removing info” from the key, but making sure the key reflects the row’s identity rather than its position.
This aligns with React’s own guidance:
I included a sandbox demo showing how the current implementation causes focus loss.