Skip to content

Commit

Permalink
Prevent a gap within Grid rows in some resize situations. (#11918)
Browse files Browse the repository at this point in the history
Fixes #11892
  • Loading branch information
Ansku committed Mar 17, 2020
1 parent 932bc47 commit 1313bbb
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions client/src/main/java/com/vaadin/client/widgets/Escalator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4578,7 +4578,7 @@ public void verifyEscalatorCount() {
// for a gap if a details row is later closed (e.g. by user)
final int addToBottom = Math.min(rowDiff,
getRowCount() - logicalTargetIndex);
final int addToTop = rowDiff - addToBottom;
final int addToTop = Math.max(rowDiff - addToBottom, 0);

if (addToTop > 0) {
fillAndPopulateEscalatorRowsIfNeeded(0,
Expand All @@ -4587,8 +4587,30 @@ public void verifyEscalatorCount() {
updateTopRowLogicalIndex(-addToTop);
}
if (addToBottom > 0) {
fillAndPopulateEscalatorRowsIfNeeded(visualTargetIndex,
logicalTargetIndex, addToBottom);
// take into account that rows may have got added to top as
// well, affects visual but not logical indexing
fillAndPopulateEscalatorRowsIfNeeded(
visualTargetIndex + addToTop, logicalTargetIndex,
addToBottom);

// adding new rows due to resizing may have created a gap in
// the middle, check whether the existing rows need moving
double rowTop = getRowTop(oldTopRowLogicalIndex);
if (rowTop > getRowTop(visualRowOrder.get(addToTop))) {
for (int i = addToTop; i < visualTargetIndex; i++) {

final TableRowElement tr = visualRowOrder.get(i);

setRowPosition(tr, 0, rowTop);
rowTop += getDefaultRowHeight();
SpacerContainer.SpacerImpl spacer = spacerContainer
.getSpacer(oldTopRowLogicalIndex + i);
if (spacer != null) {
spacer.setPosition(0, rowTop);
rowTop += spacer.getHeight();
}
}
}
}
} else if (rowDiff < 0) {
// rows need to be removed
Expand Down

0 comments on commit 1313bbb

Please sign in to comment.