aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-07-11 22:06:59 +0300
committerMehdi Javan <32511762+mehdi-vaadin@users.noreply.github.com>2018-07-13 13:48:13 +0300
commit4f12d69dd65c4c103706112e75e8929527b8c62d (patch)
tree27d3b8bb2a784a9f32a58856be9fd14b7a3c24a4
parent48a6ade74d89eccbb10fe04be9f08276cca1beef (diff)
downloadvaadin-framework-4f12d69dd65c4c103706112e75e8929527b8c62d.tar.gz
vaadin-framework-4f12d69dd65c4c103706112e75e8929527b8c62d.zip
Fix canceling Grid Editor during EditorOpenEvent (#11038)
Fixes #11002 (cherry picked from commit 578e11e)
-rw-r--r--server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java2
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java9
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java13
3 files changed, 23 insertions, 1 deletions
diff --git a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
index d252cfed99..8f97e59ba9 100644
--- a/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
+++ b/server/src/main/java/com/vaadin/ui/components/grid/EditorImpl.java
@@ -148,8 +148,8 @@ public class EditorImpl<T> extends AbstractGridExtension<T>
return;
}
doClose();
- doEdit(getData(key));
rpc.confirmBind(true);
+ doEdit(getData(key));
}
});
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
index 0e196b46ed..b00ba210f3 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.stream.Stream;
@@ -804,6 +805,14 @@ public class GridBasics extends AbstractTestUIWithLog {
editorMenu.addItem("Edit last row", menuItem -> grid.getEditor()
.editRow(grid.getDataCommunicator().getDataProviderSize() - 1));
+ editorMenu.addItem("Cancel next edit", menuItem -> {
+ AtomicReference<Registration> reference = new AtomicReference<>();
+ reference.set(grid.getEditor().addOpenListener(e -> {
+ e.getGrid().getEditor().cancel();
+ reference.get().remove();
+ }));
+ });
+
editorMenu.addItem("Change save caption",
event -> grid.getEditor().setSaveCaption("ǝʌɐS"));
editorMenu.addItem("Change cancel caption",
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java
index 5dc4b42303..aeaf34d529 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java
@@ -239,6 +239,19 @@ public abstract class GridEditorTest extends GridBasicsTest {
.findElement(By.className("not-editable")).getText());
}
+ @Test
+ public void testEditorCancelOnOpen() {
+ editRow(2);
+ getGridElement().sendKeys(Keys.ESCAPE);
+
+ selectMenuPath("Component", "Editor", "Cancel next edit");
+ getGridElement().getCell(2, 0).doubleClick();
+ assertEditorClosed();
+
+ editRow(2);
+ assertNoErrorNotifications();
+ }
+
protected WebElement getSaveButton() {
return getDriver().findElement(BY_EDITOR_SAVE);
}