The related tests have a workaround for another (Chrome specific) GridLayout bug #9921.
Those workarounds should be removed once that issue is fixed.
Fixes #9148
items.add(item);
}
getWidget().buildOptions(items);
+ getLayoutManager().setNeedsMeasure(this);
}
@Override
options.add(dataSource.getRow(i));
}
select.buildOptions(options);
+ getLayoutManager().setNeedsMeasure(this);
updateSelectedItem();
}
-Subproject commit 52b1a4148ba8b3a6a74278e4d7d041aa6d6620b7
+Subproject commit 0cff74a59932e44a89ea1146b0e4b56b9928a209
--- /dev/null
+package com.vaadin.tests.components.checkboxgroup;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBoxGroup;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.themes.ValoTheme;
+
+public class CheckBoxGroupInGridLayout extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ CheckBoxGroup<String> cbGroup = new CheckBoxGroup<>(null, DataProvider.ofItems("A", "B", "C"));
+ cbGroup.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
+
+ GridLayout gridLayout = new GridLayout(2, 1);
+ gridLayout.addComponent(cbGroup, 0, 0);
+ gridLayout.setSpacing(true);
+
+ gridLayout.addComponent(new TextField(), 1, 0);
+
+ addComponent(gridLayout);
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.radiobuttongroup;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.RadioButtonGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.themes.ValoTheme;
+
+public class RadioButtonGroupInGridLayout extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ RadioButtonGroup<String> cbGroup = new RadioButtonGroup<>(null, DataProvider.ofItems("A", "B", "C"));
+ cbGroup.addStyleName(ValoTheme.OPTIONGROUP_HORIZONTAL);
+
+ GridLayout gridLayout = new GridLayout(2, 1);
+ gridLayout.addComponent(cbGroup, 0, 0);
+ gridLayout.setSpacing(true);
+
+ gridLayout.addComponent(new TextField(), 1, 0);
+
+ addComponent(gridLayout);
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.checkboxgroup;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.CheckBoxGroupElement;
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class CheckBoxGroupInGridLayoutTest extends MultiBrowserTest {
+
+ @Test
+ public void slotSizeRemainsUnchangedAfterSelectingItem() {
+ openTestURL();
+ GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
+ int before = gridLayout.getSize().getWidth();
+
+ CheckBoxGroupElement checkBoxGroup = $(CheckBoxGroupElement.class)
+ .first();
+ checkBoxGroup.setValue("A");
+ int after = gridLayout.getSize().getWidth();
+
+ boolean ok = (before == after);
+ // also accept broken layout for unrelated bug #9921 until it is fixed
+ if (!ok && BrowserUtil.isChrome(getDesiredCapabilities())) {
+ ok = (before == after + 4);
+ }
+
+ Assert.assertTrue("GridLayout size changed when selecting a value", ok);
+ }
+}
--- /dev/null
+package com.vaadin.tests.components.radiobuttongroup;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.GridLayoutElement;
+import com.vaadin.testbench.elements.RadioButtonGroupElement;
+import com.vaadin.testbench.parallel.BrowserUtil;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class RadioButtonGroupInGridLayoutTest extends MultiBrowserTest {
+
+ @Test
+ public void slotSizeRemainsUnchangedAfterSelectingItem() {
+ openTestURL();
+ GridLayoutElement gridLayout = $(GridLayoutElement.class).first();
+ int before = gridLayout.getSize().getWidth();
+
+ RadioButtonGroupElement radioButtonGroup = $(
+ RadioButtonGroupElement.class).first();
+ radioButtonGroup.setValue("A");
+ int after = gridLayout.getSize().getWidth();
+
+ boolean ok = (before == after);
+ // also accept broken layout for unrelated bug #9921 until it is fixed
+ if (!ok && BrowserUtil.isChrome(getDesiredCapabilities())) {
+ ok = (before == after + 4);
+ }
+
+ Assert.assertTrue("GridLayout size changed when selecting a value", ok);
+ }
+}