diff options
author | Matti Tahvonen <matti@vaadin.com> | 2017-09-06 12:25:09 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-06 12:25:09 +0300 |
commit | 7427cd2d6504927fed880ebd23f2e3e7c7c102dc (patch) | |
tree | 42159d0cb47a059177a9d753e5e5d9681ae1280e | |
parent | 5df3c0ac7b6d851b30e333fee52bf992fe6e804a (diff) | |
download | vaadin-framework-7427cd2d6504927fed880ebd23f2e3e7c7c102dc.tar.gz vaadin-framework-7427cd2d6504927fed880ebd23f2e3e7c7c102dc.zip |
Fix invalid user visible value in ComboBox (#8115)
Closes #7902
3 files changed, 43 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java index e407aaafe4..af58756af0 100644 --- a/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java +++ b/client/src/main/java/com/vaadin/client/ui/VFilterSelect.java @@ -1872,7 +1872,6 @@ public class VFilterSelect extends Composite client.updateVariable(paintableId, "selected", new String[] { selectedOptionKey }, immediate); afterUpdateClientVariables(); - // currentPage = -1; // forget the page } @@ -2644,6 +2643,7 @@ public class VFilterSelect extends Composite public void setSelectedCaption(String selectedCaption) { explicitSelectedCaption = selectedCaption; if (selectedCaption != null) { + selectedOptionKey = null; setPromptingOff(selectedCaption); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java index 1b0675c914..8899fa2b69 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabled.java @@ -5,8 +5,11 @@ import java.util.ArrayList; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.tests.components.ComponentTestCase; +import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Notification; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; public class ComboBoxScrollingToPageDisabled extends ComponentTestCase<ComboBox> { @@ -20,12 +23,30 @@ public class ComboBoxScrollingToPageDisabled @Override protected void initializeComponents() { - ComboBox s = createSelect(null); + final ComboBox s = createSelect(null); s.setScrollToSelectedItem(false); populate(s, 100); - Object selection = new ArrayList<Object>(s.getItemIds()).get(50); + final Object selection = new ArrayList<Object>(s.getItemIds()).get(50); s.setValue(selection); addTestComponent(s); + + Button button = new Button("Select first"); + button.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + s.setValue(s.getItemIds().iterator().next()); + } + }); + addComponent(button); + + Button button2 = new Button("Select index 50"); + button2.addClickListener(new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + s.setValue(selection); + } + }); + addComponent(button2); } private void populate(ComboBox s, int nr) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java index 698a5fb49f..8d18865944 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxScrollingToPageDisabledTest.java @@ -17,6 +17,7 @@ package com.vaadin.tests.components.combobox; import org.junit.Test; +import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.LabelElement; import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.newelements.ComboBoxElement; @@ -50,4 +51,22 @@ public class ComboBoxScrollingToPageDisabledTest extends MultiBrowserTest { org.junit.Assert.assertEquals("Item 99", combo.getText()); } + + @Test + public void checkUpdateFromServerDisplayedCorrectly() { + ButtonElement selFirstButton = $(ButtonElement.class) + .caption("Select first").first(); + ButtonElement sel50Button = $(ButtonElement.class) + .caption("Select index 50").first(); + ComboBoxElement comboBox = $(ComboBoxElement.class).first(); + + selFirstButton.click(); + org.junit.Assert.assertEquals("Item 0", comboBox.getText()); + sel50Button.click(); + org.junit.Assert.assertEquals("Item 50", comboBox.getText()); + selFirstButton.click(); + org.junit.Assert.assertEquals("Item 0", comboBox.getText()); + sel50Button.click(); + org.junit.Assert.assertEquals("Item 50", comboBox.getText()); + } } |