Skip to content

Commit 0058115

Browse files
committed
refactor: do not scroll by default on getrows and update javadocs
1 parent 5a846ec commit 0058115

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

vaadin-grid-flow-parent/vaadin-grid-flow-integration-tests/src/test/java/com/vaadin/flow/component/grid/it/ComponentColumnWithHeightIT.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public void shouldPositionItemsCorrectlyAfterUpdatingComponentRenderers() {
5454

5555
@Test
5656
public void shouldPositionItemsCorrectlyAfterScrollingToEnd() {
57-
int initialLastRow = grid.getRowCount() - 1;
58-
var row = grid.getRow(initialLastRow);
59-
int expected = row.getLocation().y + row.getSize().height;
57+
var initialLastRow = grid.getRowCount() - 1;
58+
var row = grid.getRow(initialLastRow, true);
59+
var expectedPosition = row.getLocation().y + row.getSize().height;
6060

6161
add.click();
6262
// Expect the y position of the last row to equal the y position + the
6363
// height of the previous row
64-
Assert.assertEquals(expected,
65-
grid.getRow(initialLastRow + 1, false).getLocation().y);
64+
Assert.assertEquals(expectedPosition,
65+
grid.getRow(initialLastRow + 1).getLocation().y);
6666
}
6767
}

vaadin-grid-flow-parent/vaadin-grid-testbench/src/main/java/com/vaadin/flow/component/grid/testbench/GridElement.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -234,26 +234,32 @@ public List<GridTRElement> getRows(int firstRowIndex, int lastRowIndex)
234234
}
235235

236236
/**
237-
* Gets the <code>tr</code> element for the given row index.
237+
* Gets the {@code tr} element for the given row index.
238238
*
239239
* @param rowIndex
240240
* the row index
241-
* @return the tr element for the row
241+
* @return the {@code tr} element for the row, or {@code null} if the row is
242+
* not in viewport
242243
* @throws IndexOutOfBoundsException
243244
* if no row with given index exists
244245
*/
245246
public GridTRElement getRow(int rowIndex) throws IndexOutOfBoundsException {
246-
return getRow(rowIndex, true);
247+
return getRow(rowIndex, false);
247248
}
248249

249250
/**
250-
* Gets the <code>tr</code> element for the given row index.
251+
* Gets the {@code tr} element for the given row index.
252+
* <p>
253+
* Returns {@code null} if the row is not in viewport and the provided
254+
* {@code scroll} parameter is {@code false}.
251255
*
252256
* @param rowIndex
253257
* the row index
254258
* @param scroll
255-
* scroll to index to reveal the row
256-
* @return the tr element for the row
259+
* whether to scroll to the row index
260+
* @return the {@code tr} element for the row, or {@code null} if the row is
261+
* not in viewport and the provided {@code scroll} parameter is
262+
* {@code false}
257263
* @throws IndexOutOfBoundsException
258264
* if no row with given index exists
259265
*/

0 commit comments

Comments
 (0)