summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorHenrik Paul <henrik@vaadin.com>2014-11-21 13:41:40 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2014-11-27 12:42:59 +0000
commitfbfca1e9fc7a77e02c4262f0dfbe7ff408633499 (patch)
treeb648f7c7c38586dfbfdf76a70bcece7a573531c0 /client/src
parent227bd83276810ffbae87b582c985b2702595cf42 (diff)
downloadvaadin-framework-fbfca1e9fc7a77e02c4262f0dfbe7ff408633499.tar.gz
vaadin-framework-fbfca1e9fc7a77e02c4262f0dfbe7ff408633499.zip
Removing more than pageful in Escalator doesn't break anymore (#13334)
Change-Id: I4872766d9ed49d4a0765d28ed00e84cecf24dda4
Diffstat (limited to 'client/src')
-rw-r--r--client/src/com/vaadin/client/ui/grid/Escalator.java47
1 files changed, 41 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ui/grid/Escalator.java b/client/src/com/vaadin/client/ui/grid/Escalator.java
index 4262ab53a0..aeaf6d9f1c 100644
--- a/client/src/com/vaadin/client/ui/grid/Escalator.java
+++ b/client/src/com/vaadin/client/ui/grid/Escalator.java
@@ -2150,7 +2150,9 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
"topRowLogicalIndex: " + this.topRowLogicalIndex
+ " -> " + topRowLogicalIndex);
}
- assert topRowLogicalIndex >= 0 : "topRowLogicalIndex became negative";
+ assert topRowLogicalIndex >= 0 : "topRowLogicalIndex became negative (top left cell contents: "
+ + visualRowOrder.getFirst().getCells().getItem(0)
+ .getInnerText() + ") ";
/*
* if there's a smart way of evaluating and asserting the max index,
* this would be a nice place to put it. I haven't found out an
@@ -2882,19 +2884,52 @@ public class Escalator extends Widget implements RequiresResize, DeferredWorker
removedVisualInside, 0);
}
+ else if (removedVisualInside.contains(0)
+ && numberOfRows >= visualRowOrder.size()) {
+ /*
+ * We're removing so many rows that the viewport is
+ * pushed up more than a screenful. This means we can
+ * simply scroll up and everything will work without a
+ * sweat.
+ */
+
+ double left = horizontalScrollbar.getScrollPos();
+ int top = contentBottom - visualRowOrder.size()
+ * getDefaultRowHeight();
+ setBodyScrollPosition(left, top);
+
+ Range allEscalatorRows = Range.withLength(0,
+ visualRowOrder.size());
+ int logicalTargetIndex = getRowCount()
+ - allEscalatorRows.length();
+ moveAndUpdateEscalatorRows(allEscalatorRows, 0,
+ logicalTargetIndex);
+
+ /*
+ * Scrolling the body to the correct location will be
+ * fixed automatically. Because the amount of rows is
+ * decreased, the viewport is pushed up as the scrollbar
+ * shrinks. So no need to do anything there.
+ *
+ * TODO [[optimize]]: This might lead to a double body
+ * refresh. Needs investigation.
+ */
+ }
+
else if (contentBottom
+ (numberOfRows * getDefaultRowHeight())
- viewportBottom < getDefaultRowHeight()) {
/*
- * FIXME [[rowheight]]: above coded to work only with
- * default row heights - will not work with variable row
- * heights
+ * We're at the end of the row container, everything is
+ * added to the top.
*/
/*
- * We're at the end of the row container, everything is
- * added to the top.
+ * FIXME [[rowheight]]: above if-clause is coded to only
+ * work with default row heights - will not work with
+ * variable row heights
*/
+
paintRemoveRowsAtBottom(removedLogicalInside,
removedVisualInside);
updateTopRowLogicalIndex(-removedLogicalInside.length());