summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-10-17 17:16:45 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2014-10-23 14:03:06 +0000
commit43c43cfe883edf776657a787332d43aa9482f6bb (patch)
tree877450e17a9089e4513dab3802b5b6da4122c162 /client
parent7622128012cd60bb82612a18b7c6582ac0e842ae (diff)
downloadvaadin-framework-43c43cfe883edf776657a787332d43aa9482f6bb.tar.gz
vaadin-framework-43c43cfe883edf776657a787332d43aa9482f6bb.zip
Fixes an issue with onUnload() (#13334)
Change-Id: I7ed22d97ee861208822f845068b7eee856392c07
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/grid/Escalator.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java
index be831b5b61..c054331c00 100644
--- a/client/src/com/vaadin/client/ui/grid/Escalator.java
+++ b/client/src/com/vaadin/client/ui/grid/Escalator.java
@@ -2646,10 +2646,7 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
return;
}
- final Range viewportRange = Range.withLength(
- getLogicalRowIndex(visualRowOrder.getFirst()),
- visualRowOrder.size());
-
+ final Range viewportRange = getVisibleRowRange();
final Range removedRowsRange = Range
.withLength(index, numberOfRows);
@@ -2721,12 +2718,12 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
int escalatorRowCount = bodyElem.getChildCount();
/*
- * If we're left with less rows than the number of escalators,
- * remove the unused ones.
+ * remember: the rows have already been subtracted from the row
+ * count at this point
*/
- final int escalatorRowsToRemove = escalatorRowCount
- - getRowCount();
- if (escalatorRowsToRemove > 0) {
+ int rowsLeft = getRowCount();
+ if (rowsLeft < escalatorRowCount) {
+ int escalatorRowsToRemove = escalatorRowCount - rowsLeft;
for (int i = 0; i < escalatorRowsToRemove; i++) {
final TableRowElement tr = visualRowOrder
.remove(removedVisualInside.getStart());
@@ -4056,9 +4053,27 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
scroller.detachMousewheelListener(getElement());
scroller.detachTouchListeners(getElement());
+ /*
+ * We can call paintRemoveRows here, because static ranges are simple to
+ * remove.
+ */
header.paintRemoveRows(0, header.getRowCount());
footer.paintRemoveRows(0, footer.getRowCount());
- body.paintRemoveRows(0, body.getRowCount());
+
+ /*
+ * We can't call body.paintRemoveRows since it relies on rowCount to be
+ * updated correctly. Since it isn't, we'll simply and brutally rip out
+ * the DOM elements (in an elegant way, of course).
+ */
+ int rowsToRemove = bodyElem.getChildCount();
+ for (int i = 0; i < rowsToRemove; i++) {
+ int index = rowsToRemove - i - 1;
+ TableRowElement tr = bodyElem.getRows().getItem(index);
+ body.paintRemoveRow(tr, index);
+ body.removeRowPosition(tr);
+ }
+ body.visualRowOrder.clear();
+ body.setTopRowLogicalIndex(0);
super.onUnload();
}