From f65e90d979d1ebacbef35d058b0bbf8e0349d0e3 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Wed, 7 Sep 2011 10:16:25 +0000 Subject: #7326 Width recalculation does not work for GridLayout inside CustomComponent svn changeset:20901/svn branch:6.7 --- .../terminal/gwt/client/ui/VCustomComponent.java | 9 +++++ .../CustomComponentGrowingContent.html | 32 +++++++++++++++++ .../CustomComponentGrowingContent.java | 42 ++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html create mode 100644 tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java index 35ed2c5fed..a95f399855 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCustomComponent.java @@ -123,6 +123,15 @@ public class VCustomComponent extends SimplePanel implements Container { } public boolean requestLayout(Set child) { + // If a child grows in size, it will not necessarily be calculated + // correctly unless we remove previous size definitions + if (isDynamicWidth()) { + getElement().getStyle().setProperty("width", ""); + } + if (isDynamicHeight()) { + getElement().getStyle().setProperty("width", ""); + } + return !updateDynamicSize(); } diff --git a/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html new file mode 100644 index 0000000000..8687057e64 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.html @@ -0,0 +1,32 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.layouts.CustomComponentWithGridLayout?restartApplication
clickvaadin=runcomvaadintestslayoutsCustomComponentWithGridLayout::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
screenCapture
+ + diff --git a/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java new file mode 100644 index 0000000000..9a559f7414 --- /dev/null +++ b/tests/src/com/vaadin/tests/components/customcomponent/CustomComponentGrowingContent.java @@ -0,0 +1,42 @@ +package com.vaadin.tests.components.customcomponent; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.GridLayout; +import com.vaadin.ui.Label; + +public class CustomComponentGrowingContent extends TestBase { + @Override + protected void setup() { + final Label label = new Label("Short content"); + label.setWidth(null); + + addComponent(new CustomComponent() { + { + GridLayout mainLayout = new GridLayout(1, 1); + mainLayout.addComponent(label); + mainLayout.setSizeUndefined(); + setSizeUndefined(); + setCompositionRoot(mainLayout); + } + }); + + addComponent(new Button("Set long content", new Button.ClickListener() { + public void buttonClick(ClickEvent event) { + label.setValue("Longer content that should be fully visible"); + } + })); + } + + @Override + protected String getDescription() { + return "The width of the custom component should increase when its content grows"; + } + + @Override + protected Integer getTicketNumber() { + return Integer.valueOf(7326); + } +} \ No newline at end of file -- cgit v1.2.3