Procházet zdrojové kódy

Fix ListSelect scrolling behavior on IE (#9910)

Fixes #9894
tags/7.7.11
Aleksi Hietanen před 6 roky
rodič
revize
5df3c0ac7b

+ 7
- 0
client/src/main/java/com/vaadin/client/ui/VListSelect.java Zobrazit soubor

@@ -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,

+ 39
- 0
uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectJumpTest.java Zobrazit soubor

@@ -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));
}
}

Načítá se…
Zrušit
Uložit