diff options
author | Henri Sara <henri.sara@itmill.com> | 2010-05-26 10:29:49 +0000 |
---|---|---|
committer | Henri Sara <henri.sara@itmill.com> | 2010-05-26 10:29:49 +0000 |
commit | 0f9f3a60edc27396876933089051e0d6f88e17e2 (patch) | |
tree | 76e8175638992e27b399c8332123fb97f30ddc32 | |
parent | afe57627e3f576ec884a3489753a5fe15f508a4b (diff) | |
download | vaadin-framework-0f9f3a60edc27396876933089051e0d6f88e17e2.tar.gz vaadin-framework-0f9f3a60edc27396876933089051e0d6f88e17e2.zip |
#5053 Last ComboBox item may not be shown if null selection enabled: test case and fix
svn changeset:13371/svn branch:6.3
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java | 14 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/tickets/Ticket5053.java | 35 |
2 files changed, 43 insertions, 6 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index 32b2323f95..66e712f4da 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -200,11 +200,13 @@ public class VFilterSelect extends Composite implements Paintable, Field, topPosition += tb.getOffsetHeight(); setPopupPosition(x, topPosition); - final int first = currentPage * pageLength - + (nullSelectionAllowed && currentPage > 0 ? 0 : 1); - final int last = first + currentSuggestions.size() - 1; - final int matches = totalSuggestions - - (nullSelectionAllowed ? 1 : 0); + int nullOffset = (nullSelectionAllowed ? 1 : 0); + boolean firstPage = (currentPage == 0); + final int first = currentPage * pageLength + 1 + - (firstPage ? 0 : nullOffset); + final int last = first + currentSuggestions.size() - 1 + - (firstPage ? nullOffset : 0); + final int matches = totalSuggestions - nullOffset; if (last > 0) { // nullsel not counted, as requested by user DOM.setInnerText(status, (matches == 0 ? 0 : first) @@ -217,7 +219,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, } // We don't need to show arrows or statusbar if there is only one // page - if (matches <= pageLength) { + if (totalSuggestions <= pageLength) { setPagingEnabled(false); } else { setPagingEnabled(true); diff --git a/tests/src/com/vaadin/tests/tickets/Ticket5053.java b/tests/src/com/vaadin/tests/tickets/Ticket5053.java new file mode 100644 index 0000000000..bbb9a1ebc2 --- /dev/null +++ b/tests/src/com/vaadin/tests/tickets/Ticket5053.java @@ -0,0 +1,35 @@ +package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Window;
+
+/**
+ * #5053: Last ComboBox item may not be shown if null selection enabled
+ */
+public class Ticket5053 extends Application {
+
+ @Override
+ public void init() {
+ Window main = new Window();
+ setMainWindow(main);
+
+ ComboBox combobox = new ComboBox("My ComboBox");
+
+ // Enable null selection
+ combobox.setNullSelectionAllowed(true);
+ // Add the item that marks 'null' value
+ String nullitem = "-- none --";
+ combobox.addItem(nullitem);
+ // Designate it was the 'null' value marker
+ combobox.setNullSelectionItemId(nullitem);
+
+ // Add some other items
+ for (int i = 0; i < 10; i++) {
+ combobox.addItem("Item " + i);
+ }
+
+ main.addComponent(combobox);
+ }
+
+}
|