diff options
author | Tatu Lund <tatu@vaadin.com> | 2019-06-26 13:42:10 +0300 |
---|---|---|
committer | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-26 13:42:10 +0300 |
commit | 487e450c61dd2eeaa32da3ec048dd0efb8fc7aa2 (patch) | |
tree | 9d1104fd515cbf82d538f7b47790e30a3cfa7718 | |
parent | 3652c3a8f1ed7fc8f6e27fb2242027732fa41404 (diff) | |
download | vaadin-framework-487e450c61dd2eeaa32da3ec048dd0efb8fc7aa2.tar.gz vaadin-framework-487e450c61dd2eeaa32da3ec048dd0efb8fc7aa2.zip |
Adding css class to Editor when on selected row (#11636)
* Adding "v-grid-editor-selected" stylename in editor cell wrapper element when Grid is opened on selected row.
-rwxr-xr-x | client/src/main/java/com/vaadin/client/widgets/Grid.java | 9 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java | 24 |
2 files changed, 33 insertions, 0 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 4c88879ad1..6537b8642c 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -1908,6 +1908,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>, updateBufferedStyleName(); + // Add class name with selected modifier if the editor is being + // opened on selected row, see #11634 + String selectedStylename = styleName + "-selected"; + if (grid.isSelected(grid.getDataSource().getRow(getRow()))) { + cellWrapper.addClassName(selectedStylename); + } else { + cellWrapper.removeClassName(selectedStylename); + } + int frozenColumns = grid.getVisibleFrozenColumnCount(); double frozenColumnsWidth = 0; double cellHeight = 0; diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java index bb9ba916d8..7cdc9a43d0 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridSelectionTest.java @@ -39,6 +39,30 @@ public class GridSelectionTest extends GridBasicsTest { } @Test + public void testEditorSelectOnOff() throws Exception { + openTestURL(); + + selectMenuPath("Component", "Editor", "Enabled"); + + selectMenuPath("Component", "Editor", "Edit row 0"); + waitForElementVisible(By.className("v-grid-editor")); + assertFalse("editor should not be selected", editorIsSelected()); + getGridElement().getEditor().cancel(); + + toggleFirstRowSelection(); + selectMenuPath("Component", "Editor", "Edit row 0"); + waitForElementVisible(By.className("v-grid-editor")); + assertTrue("editor should become selected", editorIsSelected()); + getGridElement().getEditor().cancel(); + } + + private boolean editorIsSelected() { + WebElement cellWrapperElement = findElements( + By.className("v-grid-editor-cells")).get(1); + return cellWrapperElement.getAttribute("class").contains("-selected"); + } + + @Test public void testSelectOnScrollOffScroll() throws Exception { openTestURL(); |