Skip to content

GridElement.getRow() returns null even if it shouldn't #1892

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

Closed
mvysny opened this issue Mar 28, 2025 · 2 comments · Fixed by vaadin/flow-components#7260
Closed

GridElement.getRow() returns null even if it shouldn't #1892

mvysny opened this issue Mar 28, 2025 · 2 comments · Fixed by vaadin/flow-components#7260
Labels
documentation Improvements or additions to documentation

Comments

@mvysny
Copy link
Member

mvysny commented Mar 28, 2025

If you attempt to call GridElement.getRow() on a row that's not currently being shown in grid's viewport, you'll get null. The problem is that the function doesn't mention this at all in the javadoc.

The solution would be either:

  1. To mention explicitly that a null value can be returned when the rowIndex is outside of getFirstVisibleRowIndex()/getLastVisibleRowIndex() or isRowInView()
  2. Or use scrollToRow() to make sure the result value is never null.

Also document what the function will return if the index is out of bounds (e.g. -1 or rowCount+1)

@stefanuebe
Copy link

Same like this #1515?

@mvysny
Copy link
Member Author

mvysny commented Mar 28, 2025

Very similar indeed, but the behavior is different: null vs NPE. I'd keep both tickets open until we figure out what the function should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Development

Successfully merging a pull request may close this issue.

3 participants