aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-12-19 11:08:18 +0200
committerOlli Tietäväinen <ollit@vaadin.com>2017-12-19 11:08:18 +0200
commit31fb84fc6f23ac2bd47bb2e9dfe95399bbee5ec4 (patch)
tree66a39a5af01c39cd4ed4e9c521ccd1078f38c0f9
parented7059e48523d4fea7056e55faa1d2ad2c5ba614 (diff)
downloadvaadin-framework-31fb84fc6f23ac2bd47bb2e9dfe95399bbee5ec4.tar.gz
vaadin-framework-31fb84fc6f23ac2bd47bb2e9dfe95399bbee5ec4.zip
Fix column width resize event firing when mode is SIMPLE (#10452)
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java12
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java30
2 files changed, 40 insertions, 2 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java
index 857f95002f..be4d3da587 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -5888,9 +5888,17 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
@Override
public void onComplete() {
dragEnded();
-
col.setWidth(width);
- fireEvent(new ColumnResizeEvent<T>(col));
+
+ // Need to wait for column width recalculation
+ // scheduled by setWidth() before firing the event
+ Scheduler.get().scheduleDeferred(
+ new ScheduledCommand() {
+ @Override
+ public void execute() {
+ fireEvent(new ColumnResizeEvent<T>(col));
+ }
+ });
}
};
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java
index d24fe19639..ac9a505f07 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/GridColumnResizeModeTest.java
@@ -23,6 +23,7 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
import com.vaadin.tests.components.grid.basicfeatures.element.CustomGridElement;
@@ -74,4 +75,33 @@ public class GridColumnResizeModeTest extends GridBasicFeaturesTest {
}
+
+ @Test
+ public void testSimpleResizeModeMultipleDrag() throws Exception {
+ CustomGridElement grid = getGridElement();
+
+ List<WebElement> handles = grid
+ .findElements(By.className("v-grid-column-resize-handle"));
+ WebElement handle = handles.get(1);
+
+ GridCellElement cell = grid.getHeaderCell(0, 1);
+
+ int initialWidth = cell.getSize().getWidth();
+
+ selectMenuPath("Component", "Columns", "Simple resize mode");
+ sleep(250);
+
+ drag(handle, 100);
+ sleep(500);
+ Assert.assertEquals(initialWidth + 100, cell.getSize().getWidth());
+
+ drag(handle, -100);
+ sleep(500);
+ Assert.assertEquals(initialWidth, cell.getSize().getWidth());
+ }
+
+ private void drag(WebElement handle, int xOffset) {
+ new Actions(getDriver()).moveToElement(handle).clickAndHold()
+ .moveByOffset(xOffset, 0).release().perform();
+ }
}