@Override
public void buildOptions(UIDL uidl) {
+ int scrollTop = select.getElement().getScrollTop();
+ int rowCount = getRows();
select.setMultipleSelect(isMultiselect());
select.clear();
if (!isMultiselect() && isNullSelectionAllowed()
if (getRows() > 0) {
select.setVisibleItemCount(getRows());
}
+ // FIXME: temporary hack for preserving the scroll state when the
+ // contents haven't been changed obviously. This should be dealt with in
+ // the rewrite.
+ if (rowCount == getRows()) {
+ select.getElement().setScrollTop(scrollTop);
+ }
}
@Override
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>ListSelectJump</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">ListSelectJump</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.listselect.ListSelectJump?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>addSelection</td>
+ <td>vaadin=runcomvaadintestscomponentslistselectListSelectJump::PID_Slistselect/domChild[0]</td>
+ <td>label=Option #1</td>
+</tr>
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentslistselectListSelectJump::PID_Slistselect/domChild[0]</td>
+ <td>135</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>addSelection</td>
+ <td>vaadin=runcomvaadintestscomponentslistselectListSelectJump::PID_Slistselect/domChild[0]</td>
+ <td>label=Option #10</td>
+</tr>
+
+<!-- hack to get Chrome and Safari back to where they are supposed to be since addSelection breaks this for them -->
+<tr>
+ <td>scroll</td>
+ <td>vaadin=runcomvaadintestscomponentslistselectListSelectJump::PID_Slistselect/domChild[0]</td>
+ <td>135</td>
+</tr>
+<tr>
+ <td>pause</td>
+ <td>300</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentslistselectListSelectJump::PID_Sbutton/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td></td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
--- /dev/null
+package com.vaadin.tests.components.listselect;
+
+import java.util.ArrayList;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.MarginInfo;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.AbstractSelect;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.ListSelect;
+
+public class ListSelectJump extends AbstractTestUI {
+
+ @Override
+ public void setup(VaadinRequest request) {
+ getLayout().setMargin(new MarginInfo(true, false, false, false));
+
+ addComponent(new Label(
+ "Instructions:<ol><li>Select Option #1</li><li><b>Also</b> select Option #10 (use meta-click)</li>"
+ + "<li>Leave the Option #10 visible in the scroll window</li><li>Press the button</li></ol>"
+ + "You will see the <code>ListSelect</code> scroll window jump back to the top.",
+ ContentMode.HTML));
+ ArrayList<String> list = new ArrayList<String>();
+ for (int i = 1; i <= 25; i++) {
+ list.add("Option #" + i);
+ }
+ ListSelect listSelect = new ListSelect(null, list);
+ listSelect.setNullSelectionAllowed(false);
+ listSelect.setMultiSelect(true);
+ listSelect.setImmediate(false);
+ listSelect.setRows(5);
+ listSelect.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ID);
+ listSelect.setId("listselect");
+ addComponent(listSelect);
+ Button button = new Button("Press Me");
+ button.setId("button");
+ addComponent(button);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "ListSelect jumps to top row after each client -> server contact";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10416;
+ }
+
+}