From 0abcf847a27cff763f3dfea6aeec04b5aeb633d4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Johannes=20Dahlstr=C3=B6m?= Date: Thu, 14 Jun 2012 13:11:37 +0000 Subject: [PATCH] #8852 Applied Sami's patch with minor changes to comments and the test svn changeset:23938/svn branch:6.8 --- .../vaadin/terminal/gwt/client/ui/VForm.java | 5 -- .../terminal/gwt/client/ui/VWindow.java | 24 ++++++-- .../UndefinedHeightSubWindowAndContent.html | 57 ++++++++++++++++++ .../UndefinedHeightSubWindowAndContent.java | 58 +++++++++++++++++++ 4 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html create mode 100644 tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java diff --git a/src/com/vaadin/terminal/gwt/client/ui/VForm.java b/src/com/vaadin/terminal/gwt/client/ui/VForm.java index c0a6e5b275..546f90a39b 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VForm.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VForm.java @@ -6,7 +6,6 @@ package com.vaadin.terminal.gwt.client.ui; import java.util.Set; -import com.google.gwt.dom.client.Style.Display; import com.google.gwt.event.dom.client.KeyDownEvent; import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.event.shared.HandlerRegistration; @@ -39,7 +38,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler { private Container lo; private Element legend = DOM.createLegend(); private Element caption = DOM.createSpan(); - private Element errorIndicatorElement = DOM.createDiv(); private Element desc = DOM.createDiv(); private Icon icon; private VErrorMessage errorMessage = new VErrorMessage(); @@ -70,9 +68,6 @@ public class VForm extends ComplexPanel implements Container, KeyDownHandler { setStyleName(CLASSNAME); fieldSet.appendChild(legend); legend.appendChild(caption); - errorIndicatorElement.setClassName("v-errorindicator"); - errorIndicatorElement.getStyle().setDisplay(Display.NONE); - errorIndicatorElement.setInnerText(" "); // needed for IE desc.setClassName("v-form-description"); fieldSet.appendChild(desc); // Adding description for initial padding // measurements, removed later if no diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 2355a9c65a..2384ee7ddd 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -390,6 +390,17 @@ public class VWindow extends VOverlay implements Container, layoutRelativeWidth = uidl.hasAttribute("layoutRelativeWidth"); layoutRelativeHeight = uidl.hasAttribute("layoutRelativeHeight"); + // Ticket #8852: We have to override min height if height of both window + // and layout have undefined height. 0 is used to as undefined value and + // replacing it with 30 will lead to calculation errors (as browser + // takes care of height modifications). + if (dynamicHeight && !layoutRelativeHeight + && !childUidl.hasAttribute("height")) { + renderSpace.setHeight(0); + } else if (renderSpace.getHeight() < MIN_CONTENT_AREA_HEIGHT) { + renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT); + } + if (dynamicWidth && layoutRelativeWidth) { /* * Relative layout width, fix window width before rendering (width @@ -1161,12 +1172,17 @@ public class VWindow extends VOverlay implements Container, return; } if (height == null || "".equals(height)) { + getElement().getStyle().clearHeight(); contentPanel.getElement().getStyle().clearHeight(); - // Reset to default, the exact value does not actually - // matter as an undefined-height parent should not have - // a relative-height child anyway. - renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT); + + // If content and window both have undefined height do not set min + // height to render space + if (renderSpace.getHeight() != 0 || !dynamicHeight + || layoutRelativeHeight) { + renderSpace.setHeight(MIN_CONTENT_AREA_HEIGHT); + } + } else { getElement().getStyle().setProperty("height", height); int contentHeight = getElement().getOffsetHeight() diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html new file mode 100644 index 0000000000..a3b56cd12a --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.html @@ -0,0 +1,57 @@ + + + + + + +UndefinedHeightSubWindowAndContent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
UndefinedHeightSubWindowAndContent
open/run/com.vaadin.tests.components.window.UndefinedHeightSubWindowAndContent?restartApplication
mouseClickvaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]52,11
enterCharactervaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]invalid
pressSpecialKeyvaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]enter
screenCaptureform_full_width_1_error
enterCharactervaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]valid
pressSpecialKeyvaadin=runcomvaadintestscomponentswindowUndefinedHeightSubWindowAndContent::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/ChildComponentContainer[0]/VForm[0]/VFormLayout[0]/VFormLayout$VFormLayoutTable[0]/VTextField[0]enter
screenCaptureform_full_width_2_valid
+ + diff --git a/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java new file mode 100644 index 0000000000..ed259b2f4c --- /dev/null +++ b/tests/testbench/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java @@ -0,0 +1,58 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.data.Validator; +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Form; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; + +public class UndefinedHeightSubWindowAndContent extends TestBase { + + @Override + protected void setup() { + Window subWindow = new Window("No scrollbars!"); + subWindow.setWidth("300px"); + subWindow.center(); + subWindow.setModal(true); + VerticalLayout layout = new VerticalLayout(); + layout.setWidth("100%"); + subWindow.setContent(layout); + + final Form form = new Form(); + form.setImmediate(true); + form.setValidationVisible(true); + form.setCaption("This is a form"); + form.setDescription("How do you do?"); + final TextField field1 = new TextField("Write here"); + field1.setImmediate(true); + field1.addValidator(new Validator() { + + public void validate(Object value) throws InvalidValueException { + if (!isValid(value)) { + throw new InvalidValueException("FAIL!"); + } + } + + public boolean isValid(Object value) { + return field1.getValue().equals("valid"); + } + }); + form.addField("Field 1", field1); + layout.addComponent(form); + + getMainWindow().addWindow(subWindow); + subWindow.bringToFront(); + } + + @Override + protected String getDescription() { + return "When both window and its content have undefined height, window must not reserve space for a scroll bar when it is not needed."; + } + + @Override + protected Integer getTicketNumber() { + return 8852; + } + +} -- 2.39.5