]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix Grid CellFocusHandler position on DataSource size reset (#16607)
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 16 Mar 2015 09:18:25 +0000 (11:18 +0200)
committerVaadin Code Review <review@vaadin.com>
Mon, 16 Mar 2015 13:39:22 +0000 (13:39 +0000)
Change-Id: Id02ff612a3f152af5341445bec769a74cfd79cfb

client/src/com/vaadin/client/widgets/Grid.java

index 8a8aa75e920b44e8d42ff739838f062a60bd45cf..cb9e9c55d11f359f9b6c18f16c1521297cbf54fc 100644 (file)
@@ -2148,10 +2148,12 @@ public class Grid<T> 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<T> 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) {