From 86cf519cd08693444ef3639aeb7b23b30e7aaf25 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 27 Jul 2015 21:48:32 +0300 Subject: Make checkbox inline-block like all other widgets (#18518) Change-Id: Ibec4c7162e9f51baff2534dfc763aa5a83cf915d --- WebContent/VAADIN/themes/base/button/checkbox.scss | 4 -- .../splitpanel/GridLayoutWithCheckbox.java | 58 +++++++++++++++++ .../splitpanel/GridLayoutWithCheckboxTest.java | 75 ++++++++++++++++++++++ 3 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckbox.java create mode 100644 uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java diff --git a/WebContent/VAADIN/themes/base/button/checkbox.scss b/WebContent/VAADIN/themes/base/button/checkbox.scss index cc6143dbc1..e46d236035 100644 --- a/WebContent/VAADIN/themes/base/button/checkbox.scss +++ b/WebContent/VAADIN/themes/base/button/checkbox.scss @@ -1,9 +1,5 @@ @mixin base-checkbox($primaryStyleName : v-checkbox) { - .#{$primaryStyleName} { - display: block; - } - .#{$primaryStyleName}, .#{$primaryStyleName} label, .#{$primaryStyleName} input, diff --git a/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckbox.java b/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckbox.java new file mode 100644 index 0000000000..0dc371e57c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckbox.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.splitpanel; + +import com.vaadin.annotations.Theme; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.data.Property.ValueChangeListener; +import com.vaadin.event.FieldEvents.TextChangeEvent; +import com.vaadin.event.FieldEvents.TextChangeListener; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.AbstractTextField.TextChangeEventMode; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.Window; + +@Theme("reindeer") +public class GridLayoutWithCheckbox extends UI { + + @Override + protected void init(VaadinRequest request) { + GridLayout grid = new GridLayout(2, 3); + grid.setWidth(500, Unit.PIXELS); + + Label l = new Label("Textfield 1:"); + grid.addComponent(l, 0, 0); + TextField textfield = new TextField(); + textfield.addTextChangeListener(new TextChangeListener() { + + @Override + public void textChange(TextChangeEvent event) { + + } + }); + textfield.setTextChangeEventMode(TextChangeEventMode.EAGER); + grid.addComponent(textfield, 1, 0); + + l = new Label("CheckBox:"); + grid.addComponent(l, 0, 1); + CheckBox checkBox = new CheckBox(); + grid.addComponent(checkBox, 1, 2); + checkBox.addValueChangeListener(new ValueChangeListener() { + + @Override + public void valueChange(ValueChangeEvent event) { + + } + }); + Window window = new Window(); + window.setWidth(300.0f, Unit.PIXELS); + window.setContent(grid); + window.setResizable(false); + window.setWidth(550, Unit.PIXELS); + + // grid.setColumnExpandRatio(1, 1); + addWindow(window); + } +} \ No newline at end of file diff --git a/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java b/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java new file mode 100644 index 0000000000..fee46c155a --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckboxTest.java @@ -0,0 +1,75 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.splitpanel; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.CheckBoxElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridLayoutWithCheckboxTest extends MultiBrowserTest { + + private TextFieldElement tf; + private WebElement tfSlot; + private CheckBoxElement cb; + private WebElement cbSlot; + private Dimension tfSize; + private Dimension tfSlotSize; + private Dimension cbSize; + private Dimension cbSlotSize; + + @Test + public void layoutShouldStayTheSame() { + openTestURL(); + tf = $(TextFieldElement.class).first(); + tfSlot = tf.findElement(By.xpath("..")); + cb = $(CheckBoxElement.class).first(); + cbSlot = cb.findElement(By.xpath("..")); + + // Doing anything with the textfield or checkbox should not affect + // layout + + tf.setValue("a"); + assertSizes(); + cb.click(); + assertSizes(); + tf.setValue("b"); + assertSizes(); + cb.click(); + assertSizes(); + + } + + private void assertSizes() { + if (tfSize == null) { + tfSize = tf.getSize(); + tfSlotSize = tfSlot.getSize(); + cbSize = cb.getSize(); + cbSlotSize = cbSlot.getSize(); + } else { + Assert.assertEquals(tfSize, tf.getSize()); + Assert.assertEquals(tfSlotSize, tfSlot.getSize()); + Assert.assertEquals(cbSize, cb.getSize()); + Assert.assertEquals(cbSlotSize, cbSlot.getSize()); + } + + } +} -- cgit v1.2.3