summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2017-05-09 09:18:47 +0300
committerHenri Sara <henri.sara@gmail.com>2017-05-10 12:37:58 +0300
commit6f9825319a80797e22c83f855fe083dd93567137 (patch)
treed56a710a9c4141e6b171e0c8fd166fdc0f0c444c
parent027b14f484f9e072ebba9b8be7d9c0f3d87d39de (diff)
downloadvaadin-framework-6f9825319a80797e22c83f855fe083dd93567137.tar.gz
vaadin-framework-6f9825319a80797e22c83f855fe083dd93567137.zip
Fix selection with space in TreeGrid/Tree
Makes subclasses of Grid call custom key and mouse event handlers.
-rwxr-xr-xclient/src/main/java/com/vaadin/client/widgets/Grid.java8
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java45
2 files changed, 49 insertions, 4 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 27db38c4a1..f94c45f780 100755
--- a/client/src/main/java/com/vaadin/client/widgets/Grid.java
+++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java
@@ -2318,7 +2318,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (!Element.is(target)) {
return null;
}
- return WidgetUtil.findWidget(Element.as(target), Grid.class);
+ return WidgetUtil.findWidget(Element.as(target), Grid.class, false);
}
/**
@@ -2385,7 +2385,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (!Element.is(target)) {
return null;
}
- return WidgetUtil.findWidget(Element.as(target), Grid.class);
+ return WidgetUtil.findWidget(Element.as(target), Grid.class, false);
}
/**
@@ -5623,7 +5623,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
if (renderer instanceof WidgetRenderer) {
try {
Widget w = WidgetUtil.findWidget(
- cell.getElement().getFirstChildElement(), null);
+ cell.getElement().getFirstChildElement());
if (w != null) {
// Logical detach
@@ -7459,7 +7459,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
}
private boolean isElementInChildWidget(Element e) {
- Widget w = WidgetUtil.findWidget(e, null);
+ Widget w = WidgetUtil.findWidget(e);
if (w == this) {
return false;
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
index b1b4da2c74..18b320abba 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridBasicFeaturesTest.java
@@ -193,6 +193,51 @@ public class TreeGridBasicFeaturesTest extends MultiBrowserTest {
}
@Test
+ public void keyboard_selection() {
+ grid.getRow(0).getCell(0).click();
+
+ // Should expand "0 | 0" without moving focus
+ new Actions(getDriver()).sendKeys(Keys.RIGHT).perform();
+ assertEquals(6, grid.getRowCount());
+ assertCellTexts(1, 0, new String[] { "1 | 0", "1 | 1", "1 | 2" });
+
+ // Should navigate 2 times down to "1 | 1"
+ new Actions(getDriver()).sendKeys(Keys.DOWN, Keys.DOWN).perform();
+ assertEquals(6, grid.getRowCount());
+ assertCellTexts(1, 0, new String[] { "1 | 0", "1 | 1", "1 | 2" });
+ assertFalse(
+ grid.getRow(0).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertFalse(
+ grid.getRow(1).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertTrue(
+ grid.getRow(2).hasClassName("v-treegrid-rowmode-row-focused"));
+
+ // Should select "1 | 1" without moving focus
+ new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
+ assertTrue(grid.getRow(2).hasClassName("v-treegrid-row-selected"));
+
+ // Should move focus but not selection
+ new Actions(getDriver()).sendKeys(Keys.UP).perform();
+ assertTrue(
+ grid.getRow(1).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertFalse(
+ grid.getRow(2).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertFalse(grid.getRow(1).hasClassName("v-treegrid-row-selected"));
+ assertTrue(grid.getRow(2).hasClassName("v-treegrid-row-selected"));
+
+ // Should select "1 | 0" without moving focus
+ new Actions(getDriver()).sendKeys(Keys.SPACE).perform();
+ assertTrue(
+ grid.getRow(1).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertFalse(
+ grid.getRow(2).hasClassName("v-treegrid-rowmode-row-focused"));
+ assertTrue(grid.getRow(1).hasClassName("v-treegrid-row-selected"));
+ assertFalse(grid.getRow(2).hasClassName("v-treegrid-row-selected"));
+
+ assertNoErrorNotifications();
+ }
+
+ @Test
public void changing_hierarchy_column() {
assertTrue(grid.getRow(0).getCell(0)
.isElementPresent(By.className("v-treegrid-expander")));