summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VListSelect.java15
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java56
2 files changed, 69 insertions, 2 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VListSelect.java b/client/src/main/java/com/vaadin/client/ui/VListSelect.java
index f1a0b868ba..2a3b98996e 100644
--- a/client/src/main/java/com/vaadin/client/ui/VListSelect.java
+++ b/client/src/main/java/com/vaadin/client/ui/VListSelect.java
@@ -26,6 +26,7 @@ import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasEnabled;
import com.google.gwt.user.client.ui.ListBox;
+import com.vaadin.client.BrowserInfo;
import com.vaadin.client.FastStringSet;
import com.vaadin.client.Focusable;
import com.vaadin.client.connectors.AbstractMultiSelectConnector.MultiSelectWidget;
@@ -119,7 +120,12 @@ public class VListSelect extends Composite
for (int i = 0; i < items.size(); i++) {
final JsonObject item = items.get(i);
// reuse existing option if possible
- final String key = MultiSelectWidget.getKey(item);
+ String key = MultiSelectWidget.getKey(item);
+ if (BrowserInfo.get().isIE11() && key != null) {
+ // IE11 doesn't handle numerical keys well on Win7,
+ // prevent incorrect type handling with extra character
+ key += " ";
+ }
if (i < select.getItemCount()) {
select.setItemText(i, MultiSelectWidget.getCaption(item));
select.setValue(i, key);
@@ -148,7 +154,12 @@ public class VListSelect extends Composite
final FastStringSet selectedItemKeys = FastStringSet.create();
for (int i = 0; i < select.getItemCount(); i++) {
if (select.isItemSelected(i)) {
- selectedItemKeys.add(select.getValue(i));
+ String key = select.getValue(i);
+ if (BrowserInfo.get().isIE11() && key != null) {
+ // remove the IE11 workaround
+ key = key.trim();
+ }
+ selectedItemKeys.add(key);
}
}
return selectedItemKeys;
diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java
new file mode 100644
index 0000000000..a5b2c6394c
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectMultiSelectionTest.java
@@ -0,0 +1,56 @@
+package com.vaadin.tests.components.listselect;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.Select;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.ListSelectElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class ListSelectMultiSelectionTest extends MultiBrowserTest {
+
+ @Override
+ protected Class<?> getUIClass() {
+ return ListSelectTestUI.class;
+ }
+
+ @Test
+ public void testShiftSelect() {
+ openTestURL();
+
+ ListSelectElement listSelect = $(ListSelectElement.class).first();
+ Select select = new Select(listSelect.getSelectElement());
+ List<WebElement> options = listSelect
+ .findElements(By.tagName("option"));
+ options.get(0).click();
+
+ List<WebElement> selected = select.getAllSelectedOptions();
+ assertEquals(1, selected.size());
+ assertEquals("Item 0", selected.get(0).getText());
+
+ new Actions(getDriver()).keyDown(Keys.SHIFT).perform();
+ options.get(1).click();
+ new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+
+ selected = select.getAllSelectedOptions();
+ assertEquals(2, selected.size());
+ assertEquals("Item 1", selected.get(1).getText());
+
+ new Actions(getDriver()).keyDown(Keys.SHIFT).perform();
+ options.get(2).click();
+ new Actions(getDriver()).keyUp(Keys.SHIFT).perform();
+
+ // ensure second shift selection added instead of moved
+ selected = select.getAllSelectedOptions();
+ assertEquals(3, selected.size());
+ assertEquals("Item 2", selected.get(2).getText());
+ assertEquals("Item 0", selected.get(0).getText());
+ }
+}