@@ -43,7 +43,9 @@ public class ComponentRendererConnector | |||
@Override | |||
public SimplePanel createWidget() { | |||
return GWT.create(SimplePanel.class); | |||
SimplePanel panel = GWT.create(SimplePanel.class); | |||
panel.setStyleName("component-wrap"); | |||
return panel; | |||
} | |||
@Override |
@@ -621,6 +621,7 @@ grid.addColumn(person -> { | |||
}, new ComponentRenderer()); | |||
---- | |||
[classname]#Components# in [classname]#Grid# [classname]#ComponentRenderer# are wrapped in a [literal]#++div++# with the style name [literal]#++component-wrap++#. This can be used to style the alignment and size of the [classname]#Component#. | |||
[[components.grid.renderer.custom]] | |||
=== Custom Renderers |
@@ -222,6 +222,11 @@ $v-grid-details-border-bottom-stripe: 1px solid darken($v-grid-row-background-co | |||
} | |||
} | |||
} | |||
// Style for ComponentRenderer wrap | |||
div.component-wrap { | |||
width: 100%; | |||
} | |||
} | |||
// Rows |
@@ -35,6 +35,7 @@ public class GridComponents extends AbstractTestUIWithLog { | |||
TextField textField = new TextField(); | |||
textField.setValue(string); | |||
textField.setWidth("100%"); | |||
// Make sure all changes are sent immediately | |||
textField.setValueChangeMode(ValueChangeMode.EAGER); | |||
textField.addValueChangeListener(e -> { |
@@ -7,6 +7,7 @@ import org.openqa.selenium.WebElement; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.ButtonElement; | |||
import com.vaadin.testbench.elements.GridElement; | |||
import com.vaadin.testbench.elements.GridElement.GridCellElement; | |||
import com.vaadin.testbench.elements.GridElement.GridRowElement; | |||
import com.vaadin.testbench.elements.NotificationElement; | |||
import com.vaadin.tests.tb3.MultiBrowserTest; | |||
@@ -55,6 +56,21 @@ public class GridComponentsTest extends MultiBrowserTest { | |||
assertRowExists(5, "Row 1005"); | |||
} | |||
@Test | |||
public void testTextFieldSize() { | |||
openTestURL(); | |||
GridCellElement cell = $(GridElement.class).first().getCell(0, 1); | |||
int cellWidth = cell.getSize().getWidth(); | |||
int fieldWidth = cell.findElement(By.tagName("input")).getSize() | |||
.getWidth(); | |||
// padding left and right, +1 to fix sub pixel issues | |||
int padding = 18 * 2 + 1; | |||
int extraSpace = Math.abs(fieldWidth - cellWidth); | |||
Assert.assertTrue("Too much unused space in cell. Expected: " + padding | |||
+ " Actual: " + extraSpace, extraSpace <= padding); | |||
} | |||
private void editTextFieldInCell(GridElement grid, int row, int col) { | |||
WebElement textField = grid.getCell(row, col) | |||
.findElement(By.tagName("input")); |