]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix using ConnectorResource icons before attaching ComboBox (#10810)
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>
Tue, 17 Apr 2018 14:40:59 +0000 (17:40 +0300)
committerIlia Motornyi <elmot@vaadin.com>
Tue, 17 Apr 2018 14:40:59 +0000 (17:40 +0300)
* Fix using ConnectorResource icons before attaching ComboBox

* Update Chrome and PhantomJS screenshots

server/src/main/java/com/vaadin/ui/ComboBox.java
uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_ANY_Chrome__third-combobox-open.png
uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_LINUX_PhantomJS_1_third-combobox-open.png
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxItemIcon.java

index ef1e7cfa845d5dc49e2c32af65868979881f191c..107e503256330861f3ee0cae1e507b70ebe6b35c 100644 (file)
@@ -842,6 +842,10 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
             Resource icon = getItemIconGenerator().apply(value);
             if (icon != null) {
                 if (icon instanceof ConnectorResource) {
+                    if (!isAttached()) {
+                        // Deferred resource generation.
+                        return;
+                    }
                     setResource("selected", icon);
                 }
                 selectedItemIcon = ResourceReference
@@ -851,6 +855,13 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
         getState().selectedItemIcon = selectedItemIcon;
     }
 
+    @Override
+    public void attach() {
+        super.attach();
+
+        updateSelectedItemIcon();
+    }
+
     @Override
     protected Element writeItem(Element design, T item, DesignContext context) {
         Element element = design.appendElement("option");
index 00cf570643f744c2d60271d85916e948d8f077d1..dfc0d3ee003ad6af43a0692a6dcf606fe859862d 100644 (file)
Binary files a/uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_ANY_Chrome__third-combobox-open.png and b/uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_ANY_Chrome__third-combobox-open.png differ
index 6c2555c5fb951b38b8e65941b76ff30423ab2c53..6e8d97204610410e2e2188592b2291534fd3c2f6 100644 (file)
Binary files a/uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_LINUX_PhantomJS_1_third-combobox-open.png and b/uitest/reference-screenshots/ComboBoxItemIconTest-testIconsInComboBox_LINUX_PhantomJS_1_third-combobox-open.png differ
index c12ef2878feeb7087f1c39b1c6d8ac11664618de..0eb3d7c97fc8ac629fb90308c12ff63c2d85b2b1 100644 (file)
@@ -72,8 +72,7 @@ public class ComboBoxItemIcon extends TestBase {
             cb.setItems(IntStream.range(0, 3).boxed());
             cb.setItemIconGenerator(iconGenerator);
 
-            // FIXME: Selecting ConnectorResource on init does not work.
-            // cb.setValue(2);
+            cb.setValue(1);
             addComponent(cb);
         }
     }