reactgrid icon indicating copy to clipboard operation
reactgrid copied to clipboard

RowRenderer crashes when ScrollableRange is empty

Open ghost opened this issue 11 months ago • 3 comments

Describe the bug When e.g. all columns of a table are marked as sticky, the scrollable range of the cell matrix can be empty. This causes RowRenderer to crash at https://github.com/silevis/reactgrid/blob/c981381f725982082fee38e6b17df70e56a60b90/src/lib/Components/RowRenderer.tsx#L42 Because cellMatrix.scrollableRange.last.column is undefined. Admittedly, this is an edge case, but it can happen in our application when the user unselects all non-mandatory columns.

Current behavior reactgrid crashes when the scrollable range is empty

Expected behavior I expect reactgrid not to crash

ghost avatar Dec 10 '24 11:12 ghost

Are there any examples that can be run? Codepen?

qiufeihong2018 avatar Dec 11 '24 02:12 qiufeihong2018

pretty trivial, I have created a small repo: https://github.com/mithodin/reactgrid-undefined-range

ghost avatar Dec 11 '24 06:12 ghost

Yes, all columns of a table are marked as sticky, the scrollable range of the cell matrix can be empty. Adding the optional chaining operator is usually aimed at accessing the properties of nested objects more safely and avoiding runtime errors that may be caused by the fact that the value of the "column" property might be undefined.

qiufeihong2018 avatar Dec 13 '24 09:12 qiufeihong2018