diff options
author | Stephen Wellington <steve@stevewellington.co.uk> | 2017-04-03 11:18:21 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-05-08 14:46:35 +0300 |
commit | 58b67162080f40b5458c10cbf41cb537172a1fde (patch) | |
tree | bafc31607fd13e44402e4282ba9dc0758341093c | |
parent | 0a0ff366849ffc2d1e5732ec1547b1a06a6efffa (diff) | |
download | vaadin-framework-58b67162080f40b5458c10cbf41cb537172a1fde.tar.gz vaadin-framework-58b67162080f40b5458c10cbf41cb537172a1fde.zip |
Fix Editor not saving values by pressing Enter (#8946)
Fixes #8945
3 files changed, 46 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 746ff2be25..eb5e38773b 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -7467,8 +7467,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, if (editor.focusedColumnIndexDOM < 0) { widget = null; } else { - widget = editor - .getWidget(getColumn(editor.focusedColumnIndexDOM)); + widget = editor.getWidget( + getVisibleColumn(editor.focusedColumnIndexDOM)); } EditorDomEvent<T> editorEvent = new EditorDomEvent<>( diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java index 17411c5a77..d6ee3e16a0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java @@ -64,6 +64,28 @@ public class GridEditorBufferedTest extends GridEditorTest { } @Test + public void testKeyboardSaveWithHiddenColumn() { + selectMenuPath("Component", "Columns", "Column 0", "Hidden"); + editRow(100); + + WebElement textField = getEditor().getField(5); + + textField.click(); + // without this, the click in the middle of the field might not be after + // the old text on some browsers + new Actions(getDriver()).sendKeys(Keys.END).perform(); + + textField.sendKeys(" changed"); + + // Save from keyboard + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + assertEditorClosed(); + assertEquals("100 changed", + getGridElement().getCell(100, 4).getText()); + } + + @Test public void testKeyboardSaveWithInvalidEdition() { makeInvalidEdition(); diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java index e41ace4a1f..b408308f7b 100644 --- a/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java +++ b/uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java @@ -64,6 +64,28 @@ public class GridEditorBufferedTest extends GridEditorTest { } @Test + public void testKeyboardSaveWithHiddenColumn() { + selectMenuPath("Component", "Columns", "Column 0", "Hidden"); + selectMenuPath(EDIT_ITEM_100); + + WebElement textField = getEditorWidgets().get(1); + + textField.click(); + // without this, the click in the middle of the field might not be after + // the old text on some browsers + new Actions(getDriver()).sendKeys(Keys.END).perform(); + + textField.sendKeys(" changed"); + + // Save from keyboard + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + assertEditorClosed(); + assertEquals("(100, 2) changed", + getGridElement().getCell(100, 1).getText()); + } + + @Test public void testKeyboardSaveWithInvalidEdition() { makeInvalidEdition(); |