Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RowRenderer crashes when ScrollableRange is empty #464

Open
ghost opened this issue Dec 10, 2024 · 3 comments
Open

RowRenderer crashes when ScrollableRange is empty #464

ghost opened this issue Dec 10, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 10, 2024

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

right: (borders.right && column.idx === lastColIdx) || !(state.cellMatrix.scrollableRange.last.column.idx === location.column.idx)

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

@qiufeihong2018
Copy link
Contributor

Are there any examples that can be run? Codepen?

@ghost
Copy link
Author

ghost commented Dec 11, 2024

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

qiufeihong2018 added a commit to qiufeihong2018/reactgrid that referenced this issue Dec 13, 2024
@qiufeihong2018
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant