import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
// we're paging w/ arrows
if (lastIndex == 0) {
// going up, select last item
- suggestionPopup.menu
- .selectItem((MenuItem) suggestionPopup.menu
- .getItems().get(PAGELENTH - 1));
+ int lastItem = PAGELENTH - 1;
+ List items = suggestionPopup.menu.getItems();
+ /*
+ * The first page can contain less than 10 items if the null
+ * selection item is filtered away
+ */
+ if (lastItem >= items.size()) {
+ lastItem = items.size() - 1;
+ }
+ suggestionPopup.menu.selectItem((MenuItem) items
+ .get(lastItem));
} else {
// going down, select first item
suggestionPopup.menu
--- /dev/null
+package com.itmill.toolkit.tests.components.combobox;
+
+import com.itmill.toolkit.tests.components.TestBase;
+import com.itmill.toolkit.ui.ComboBox;
+
+public class ComboBoxNavigation extends TestBase {
+
+ @Override
+ protected String getDescription() {
+ return "Entering e in the field and scrolling down with the arrow keys should always select the next item, also when the page changes. Scrolling back up should always select the previous item, also when changing pages.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 2214;
+ }
+
+ @Override
+ protected void setup() {
+ ComboBox cb = new ComboBox();
+ for (int i = 1; i < 100; i++) {
+ cb.addItem("Item " + i);
+ }
+
+ cb.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS);
+ addComponent(cb);
+
+ }
+
+}