diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-03-17 10:17:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-17 10:17:48 +0200 |
commit | 1313bbbe3b315885fc8a49795dc85fe85768187f (patch) | |
tree | 82c36df9879dc5d32dd3cbc27813795af28b4f04 /client/src | |
parent | 932bc470aee35fd80afd5bb9054b4392948dccb3 (diff) | |
download | vaadin-framework-1313bbbe3b315885fc8a49795dc85fe85768187f.tar.gz vaadin-framework-1313bbbe3b315885fc8a49795dc85fe85768187f.zip |
Prevent a gap within Grid rows in some resize situations. (#11918)
Fixes #11892
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/main/java/com/vaadin/client/widgets/Escalator.java | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index 7ad1cabf00..c2e70eeb96 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -4578,7 +4578,7 @@ public class Escalator extends Widget // 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, @@ -4587,8 +4587,30 @@ public class Escalator extends Widget 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 |