diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-01-13 14:58:26 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-01-13 20:20:45 +0000 |
commit | e52e34c5d53cf108a6d738dc91e0b736873ecce8 (patch) | |
tree | f69118f8d02a9d71612cc3fa24709865cc966784 | |
parent | 8e17afda2ec060f56da0626fb40b088670777e8c (diff) | |
download | vaadin-framework-e52e34c5d53cf108a6d738dc91e0b736873ecce8.tar.gz vaadin-framework-e52e34c5d53cf108a6d738dc91e0b736873ecce8.zip |
Defer Grid scrolling to avoid issues with DataSource sizes (#16189)
Change-Id: I47868ff8b139ffc8c3c95ee6cafa95b76be67914
3 files changed, 34 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/connectors/GridConnector.java b/client/src/com/vaadin/client/connectors/GridConnector.java index 593a8c8574..a2e63fc397 100644 --- a/client/src/com/vaadin/client/connectors/GridConnector.java +++ b/client/src/com/vaadin/client/connectors/GridConnector.java @@ -27,6 +27,8 @@ import java.util.Map; import java.util.Set; import java.util.logging.Logger; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ComponentConnector; import com.vaadin.client.ConnectorHierarchyChangeEvent; @@ -363,17 +365,33 @@ public class GridConnector extends AbstractHasComponentsConnector implements registerRpc(GridClientRpc.class, new GridClientRpc() { @Override public void scrollToStart() { - getWidget().scrollToStart(); + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + getWidget().scrollToStart(); + } + }); } @Override public void scrollToEnd() { - getWidget().scrollToEnd(); + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + getWidget().scrollToEnd(); + } + }); } @Override - public void scrollToRow(int row, ScrollDestination destination) { - getWidget().scrollToRow(row, destination); + public void scrollToRow(final int row, + final ScrollDestination destination) { + Scheduler.get().scheduleFinally(new ScheduledCommand() { + @Override + public void execute() { + getWidget().scrollToRow(row, destination); + } + }); } }); diff --git a/uitest/src/com/vaadin/tests/components/grid/GridSingleColumn.java b/uitest/src/com/vaadin/tests/components/grid/GridSingleColumn.java index e9987db1a8..2ab0282102 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridSingleColumn.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridSingleColumn.java @@ -44,6 +44,7 @@ public class GridSingleColumn extends AbstractTestUI { column.setHeaderCaption("Header"); addComponent(grid); + grid.scrollTo(grid.getContainerDataSource().getIdByIndex(50)); } @Override diff --git a/uitest/src/com/vaadin/tests/components/grid/GridSingleColumnTest.java b/uitest/src/com/vaadin/tests/components/grid/GridSingleColumnTest.java index 05f6b4b9f7..42eb2197bf 100644 --- a/uitest/src/com/vaadin/tests/components/grid/GridSingleColumnTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/GridSingleColumnTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; +import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.annotations.TestCategory; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -27,11 +28,20 @@ import com.vaadin.tests.tb3.MultiBrowserTest; public class GridSingleColumnTest extends MultiBrowserTest { @Test - public void headerIsVisible() { + public void testHeaderIsVisible() { openTestURL(); GridCellElement cell = $(GridElement.class).first().getHeaderCell(0, 0); Assert.assertTrue("No header available", cell.getText() .equalsIgnoreCase("header")); } + + @Test + public void testScrollDidNotThrow() { + setDebug(true); + openTestURL(); + + Assert.assertFalse("Exception when scrolling on init", + isElementPresent(NotificationElement.class)); + } } |