From: Teemu Suo-Anttila Date: Mon, 16 Mar 2015 09:18:25 +0000 (+0200) Subject: Fix Grid CellFocusHandler position on DataSource size reset (#16607) X-Git-Tag: 7.5.0.alpha1~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd700f072fb72113cd559aea60819acc85b0fda5;p=vaadin-framework.git Fix Grid CellFocusHandler position on DataSource size reset (#16607) Change-Id: Id02ff612a3f152af5341445bec769a74cfd79cfb --- diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 8a8aa75e92..cb9e9c55d1 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -2148,10 +2148,12 @@ public class Grid extends ResizeComposite implements rowWithFocus = removed.getStart() - 1; } else { if (escalator.getHeader().getRowCount() > 0) { - rowWithFocus = lastFocusedHeaderRow; + rowWithFocus = Math.min(lastFocusedHeaderRow, escalator + .getHeader().getRowCount() - 1); containerWithFocus = escalator.getHeader(); } else if (escalator.getFooter().getRowCount() > 0) { - rowWithFocus = lastFocusedFooterRow; + rowWithFocus = Math.min(lastFocusedFooterRow, escalator + .getFooter().getRowCount() - 1); containerWithFocus = escalator.getFooter(); } } @@ -4571,8 +4573,12 @@ public class Grid extends ResizeComposite implements if (newSize > oldSize) { body.insertRows(oldSize, newSize - oldSize); + cellFocusHandler.rowsAddedToBody(Range.withLength(oldSize, + newSize - oldSize)); } else if (newSize < oldSize) { body.removeRows(newSize, oldSize - newSize); + cellFocusHandler.rowsRemovedFromBody(Range.withLength( + newSize, oldSize - newSize)); } if (newSize > 0) {