// Save and close.
event.getGrid().getEditor().save();
+ FocusUtil.setFocus(event.getGrid(), true);
return true;
}
@Override
public void onClick(ClickEvent event) {
save();
+ FocusUtil.setFocus(grid, true);
}
});
@Override
public void onClick(ClickEvent event) {
cancel();
+ FocusUtil.setFocus(grid, true);
}
});
}
event.getDomEvent().stopPropagation();
// fixes https://github.com/vaadin/framework/issues/8632
- // don't mark the event as handled, in order for the next handler
- // in the handler chain (HeaderDefaultRowEventHandler) to be able to
- // receive it. This should be safe since the next handlers in the
- // chain (RendererEventHandler and CellFocusEventHandler) do not
- // react to header touches/clicks.
-// event.setHandled(true);
+ // don't mark the event as handled, in order for the next
+ // handler in the handler chain (HeaderDefaultRowEventHandler)
+ // to be able to receive it. This should be safe since the next
+ // handlers in the chain (RendererEventHandler and
+ // CellFocusEventHandler) do not react to header touches/clicks.
+
+ // event.setHandled(true);
}
}
};
new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
assertEditorClosed();
- assertEquals("100 changed",
- getGridElement().getCell(100, 4).getText());
+ assertEquals("100 changed", getGridElement().getCell(100, 4).getText());
}
@Test
assertEditorOpen();
assertEquals("(2, 0)", getGridElement().getCell(2, 0).getText());
}
+
+ @Test
+ public void testFocusWhenCancelByKeyboard() {
+ editRow(5);
+ getGridElement().getEditor().getField(0).click();
+ new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform();
+ assertTrue("Focus should be in the Grid",
+ getFocusedElement().getAttribute("class").contains("v-grid"));
+ }
+
+ @Test
+ public void testFocusWhenSaveByKeyboard() {
+ editRow(5);
+ getGridElement().getEditor().getField(0).click();
+ new Actions(getDriver()).sendKeys(Keys.ENTER).perform();
+ assertTrue("Focus should be in the Grid",
+ getFocusedElement().getAttribute("class").contains("v-grid"));
+ }
+
+ @Test
+ public void testFocusWhenSaveByClick() {
+ editRow(5);
+
+ getGridElement().getEditor()
+ .findElement(By.className("v-grid-editor-save")).click();
+
+ assertTrue("Focus should be in the Grid",
+ getFocusedElement().getAttribute("class").contains("v-grid"));
+ }
+
+ @Test
+ public void testFocusWhenCancelByClick() {
+ editRow(5);
+
+ getGridElement().getEditor()
+ .findElement(By.className("v-grid-editor-cancel")).click();
+
+ assertTrue("Focus should be in the Grid",
+ getFocusedElement().getAttribute("class").contains("v-grid"));
+ }
}
}
protected void assertEditorOpen() {
- assertTrue("Editor is supposed to be open",
- getGridElement().isElementPresent(By.vaadin("#editor")));
+ waitUntil(driver -> getGridElement()
+ .isElementPresent(By.vaadin("#editor")));
}
protected void assertEditorClosed() {
editorPos == editor.getLocation().getY());
}
- @Ignore("Needs programmatic sorting")
@Test
public void testEditorClosedOnSort() {
editRow(5);
- selectMenuPath("Component", "State", "Sort by column", "Column 0, ASC");
+ selectMenuPath("Component", "Columns", "Column 0", "Sort ASC");
assertEditorClosed();
}