diff options
author | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-02 12:39:05 +0300 |
---|---|---|
committer | Teppo Kurki <teppo.kurki@vaadin.com> | 2015-06-02 15:38:28 +0300 |
commit | ec54a601dc882333687bcef2b4fa59c02e6c4ede (patch) | |
tree | b63d04d6be7abadea150fe155d9aff071c0cbedf | |
parent | 6008e42ce8d1e796e402dfd8d3f462c502d22269 (diff) | |
download | vaadin-framework-ec54a601dc882333687bcef2b4fa59c02e6c4ede.tar.gz vaadin-framework-ec54a601dc882333687bcef2b4fa59c02e6c4ede.zip |
Update editor overlay position on Grid resize
Change-Id: I980d6fa95939273c493e8ed726aa436d9d961003
-rw-r--r-- | client/src/com/vaadin/client/widgets/Grid.java | 5 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java | 46 |
2 files changed, 51 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index cb3735c141..2717dc3580 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -7692,6 +7692,11 @@ public class Grid<T> extends ResizeComposite implements @Override public void execute() { recalculateColumnWidths(); + // Vertical resizing could make editor positioning invalid so it + // needs to be recalculated on resize + if (isEditorActive()) { + editor.updateVerticalScrollPosition(); + } } }); } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java index 4c4b1c6f8b..0a6d884251 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -30,6 +30,7 @@ import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; +import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridEditorElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; @@ -205,6 +206,51 @@ public abstract class GridEditorTest extends GridBasicFeaturesTest { assertEditorClosed(); } + public void testEditorMoveOnResize() { + selectMenuPath("Component", "Size", "Height", "500px"); + getGridElement().getCell(22, 0).doubleClick(); + assertEditorOpen(); + + GridEditorElement editor = getGridElement().getEditor(); + TestBenchElement tableWrapper = getGridElement().getTableWrapper(); + + int tableWrapperBottom = tableWrapper.getLocation().getY() + + tableWrapper.getSize().getHeight(); + int editorBottom = editor.getLocation().getY() + + editor.getSize().getHeight(); + + assertTrue("Editor should not be initially outside grid", + tableWrapperBottom - editorBottom <= 2); + + selectMenuPath("Component", "Size", "Height", "300px"); + assertEditorOpen(); + + tableWrapperBottom = tableWrapper.getLocation().getY() + + tableWrapper.getSize().getHeight(); + editorBottom = editor.getLocation().getY() + + editor.getSize().getHeight(); + + assertTrue("Editor should not be outside grid after resize", + tableWrapperBottom - editorBottom <= 2); + } + + public void testEditorDoesNotMoveOnResizeIfNotNeeded() { + selectMenuPath("Component", "Size", "Height", "500px"); + + selectMenuPath(EDIT_ITEM_5); + assertEditorOpen(); + + GridEditorElement editor = getGridElement().getEditor(); + + int editorPos = editor.getLocation().getY(); + + selectMenuPath("Component", "Size", "Height", "300px"); + assertEditorOpen(); + + assertTrue("Editor should not have moved due to resize", + editorPos == editor.getLocation().getY()); + } + protected WebElement getSaveButton() { return getDriver().findElement(By.className("v-grid-editor-save")); } |