diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2017-09-04 10:56:58 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-04 10:56:58 +0300 |
commit | 5df3c0ac7b6d851b30e333fee52bf992fe6e804a (patch) | |
tree | decc406218b4ef49c7194cd1e01b5b495877d1d3 | |
parent | 6e30d6b7d6c918a7cf7e9b9367261c8f86b8259b (diff) | |
download | vaadin-framework-5df3c0ac7b6d851b30e333fee52bf992fe6e804a.tar.gz vaadin-framework-5df3c0ac7b6d851b30e333fee52bf992fe6e804a.zip |
Fix ListSelect scrolling behavior on IE (#9910)
Fixes #9894
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VListSelect.java | 7 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectJumpTest.java | 39 |
2 files changed, 46 insertions, 0 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 82b7e9a229..df2a1011ea 100644 --- a/client/src/main/java/com/vaadin/client/ui/VListSelect.java +++ b/client/src/main/java/com/vaadin/client/ui/VListSelect.java @@ -70,6 +70,9 @@ public class VListSelect extends VOptionGroupBase { @Override public void buildOptions(UIDL uidl) { + int scrollTop = select.getElement().getScrollTop(); + int rowCount = getRows(); + select.setMultipleSelect(isMultiselect()); Set<String> previousKeys = new HashSet<String>(); @@ -111,6 +114,10 @@ public class VListSelect extends VOptionGroupBase { if (getRows() > 0) { select.setVisibleItemCount(getRows()); } + + if (rowCount == getRows()) { + select.getElement().setScrollTop(scrollTop); + } } private void updateOrCreateItem(String caption, String key, int index, diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectJumpTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectJumpTest.java new file mode 100644 index 0000000000..22839f612c --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectJumpTest.java @@ -0,0 +1,39 @@ +package com.vaadin.tests.components.listselect; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class ListSelectJumpTest extends MultiBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + return getIEBrowsersOnly(); + } + + @Test + public void list_select_does_not_change_scroll_position_when_receiving_uidl() { + openTestURL(); + WebElement listSelect = findElements(By.className("v-select-select")) + .get(0); + List<WebElement> options = listSelect + .findElements(By.tagName("option")); + options.get(0).click(); + getTestBenchCommandExecutor() + .executeScript("arguments[0].scrollTop = " + 100, listSelect); + new Actions(getDriver()).keyDown(Keys.META).perform(); + options.get(9).click(); + $(ButtonElement.class).first().click(); + Assert.assertEquals(new Long(100), (Long) getTestBenchCommandExecutor() + .executeScript("return arguments[0].scrollTop", listSelect)); + } +} |