From fd700f072fb72113cd559aea60819acc85b0fda5 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Mon, 16 Mar 2015 11:18:25 +0200 Subject: [PATCH] Fix Grid CellFocusHandler position on DataSource size reset (#16607) Change-Id: Id02ff612a3f152af5341445bec769a74cfd79cfb --- client/src/com/vaadin/client/widgets/Grid.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) { -- 2.39.5