summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2019-12-18 15:18:56 +0200
committerGitHub <noreply@github.com>2019-12-18 15:18:56 +0200
commit35883e01bcbaf5ba2f5728ea1ad03fe3eb359c5d (patch)
tree6f2d5bbce7257bf4e9d082da7d3431f20c46583f /uitest
parent10b8e0c7d59d23ef41b7a8190f5f8571411bba0c (diff)
downloadvaadin-framework-35883e01bcbaf5ba2f5728ea1ad03fe3eb359c5d.tar.gz
vaadin-framework-35883e01bcbaf5ba2f5728ea1ad03fe3eb359c5d.zip
Improvements to popup positioning for ComboBox within HorizontalLayout. (#11846)
Expand ratio and spacing can cause ComboBox to miscalculate its own position while layouting is still ongoing. Popup should not be repositioned in such circumstances in order to avoid incorrect intermediate states. Continues on #11718
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxWithinHorizontalLayout.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxWithinHorizontalLayout.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxWithinHorizontalLayout.java
new file mode 100644
index 0000000000..4ae8977a8b
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxWithinHorizontalLayout.java
@@ -0,0 +1,77 @@
+package com.vaadin.tests.components.combobox;
+
+import java.util.Arrays;
+import java.util.Iterator;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+
+public class ComboBoxWithinHorizontalLayout extends AbstractTestUI {
+
+ private ComboBox<String> comboBox;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ comboBox = new ComboBox<>();
+ comboBox.setWidth("100%");
+ comboBox.setPopupWidth(null);
+ populateWithShortItems();
+
+ HorizontalLayout content = new HorizontalLayout(new Button("1"),
+ new Button("2"), comboBox, new Button("3"));
+ content.setWidth("100%");
+ content.setExpandRatio(comboBox, 2.0f);
+ Iterator<Component> i = content.iterator();
+ while (i.hasNext()) {
+ content.setComponentAlignment(i.next(), Alignment.BOTTOM_RIGHT);
+ }
+
+ getLayout().setSpacing(true);
+ addComponent(content);
+ addComponent(new Button("Toggle items", e -> {
+ if ("Short items".equals(comboBox.getCaption())) {
+ populateWithLongItems();
+ } else {
+ populateWithShortItems();
+ }
+ }));
+ addComponent(new Button("Toggle spacing", e -> {
+ content.setSpacing(!content.isSpacing());
+ }));
+ addComponent(new Button("Toggle expand ratio", e -> {
+ if (content.getExpandRatio(comboBox) > 0.0f) {
+ content.setExpandRatio(comboBox, 0.0f);
+ } else {
+ content.setExpandRatio(comboBox, 2.0f);
+ }
+ }));
+ }
+
+ private void populateWithLongItems() {
+ comboBox.setCaption("Long items");
+ comboBox.setItems(Arrays.asList(
+ "First very, very, very, very, very long item to add",
+ "Second very long item to add", "Third very long item to add"));
+ }
+
+ private void populateWithShortItems() {
+ comboBox.setCaption("Short items");
+ comboBox.setItems(Arrays.asList("short1", "short2", "short3"));
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11718;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "ComboBox within HorizontalLayout should not get incorrect "
+ + "intermediate popup positions that cause flickering.";
+ }
+}