You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComboBoxIdenticalItems.java 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package com.vaadin.tests.components.combobox;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.tests.util.Log;
  5. import com.vaadin.ui.ComboBox;
  6. public class ComboBoxIdenticalItems extends AbstractReindeerTestUI {
  7. private Log log = new Log(5);
  8. @Override
  9. protected void setup(VaadinRequest request) {
  10. final ComboBox<String> select = new ComboBox<>("ComboBox");
  11. select.setItemCaptionGenerator(
  12. item -> item.startsWith("one") ? "One" : "Two");
  13. select.setItems("one-1", "one-2", "two");
  14. select.setEmptySelectionAllowed(false);
  15. select.addValueChangeListener(
  16. event -> log.log("Item " + select.getValue() + " selected"));
  17. addComponent(log);
  18. addComponent(select);
  19. }
  20. @Override
  21. protected String getTestDescription() {
  22. return "Keyboard selecting of a value is broken in combobox if two "
  23. + "items have the same caption. The first item's id is \"one-1\" "
  24. + "while the second one is \"one-2\". Selecting with mouse works "
  25. + "as expected but selecting with keyboard always returns the "
  26. + "object \"one-1\".";
  27. }
  28. @Override
  29. protected Integer getTicketNumber() {
  30. return 6125;
  31. }
  32. }