From 41e1a013d829f75c0bdadea40ec0b42429e2a581 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Thu, 14 Feb 2013 15:41:45 +0200 Subject: [PATCH] Interim fix for resizing of child component in AbsoluteLayout when child is 100% and layout resized (no-merge) #10427 Change-Id: I497ecc1ac88ef1b3c07d127aff3c157827088e01 --- .../com/vaadin/client/ui/VAbsoluteLayout.java | 11 +++-- .../AbsoluteLayoutResizing.html | 37 ++++++++++++++++ .../AbsoluteLayoutResizing.java | 44 +++++++++++++++++++ 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.html create mode 100644 uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.java diff --git a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java index 92a51f209d..88fbae6e88 100644 --- a/client/src/com/vaadin/client/ui/VAbsoluteLayout.java +++ b/client/src/com/vaadin/client/ui/VAbsoluteLayout.java @@ -326,6 +326,10 @@ public class VAbsoluteLayout extends ComplexPanel { Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); + + // Ensure previous heights do not affect the measures + wrapperStyle.clearHeight(); + if (widgetStyle.getHeight() != null && widgetStyle.getHeight().endsWith("%")) { int h; @@ -343,8 +347,6 @@ public class VAbsoluteLayout extends ComplexPanel { - wrapper.getElement().getOffsetTop(); } wrapperStyle.setHeight(h, Unit.PX); - } else { - wrapperStyle.clearHeight(); } wrapper.updateCaptionPosition(); @@ -380,6 +382,9 @@ public class VAbsoluteLayout extends ComplexPanel { Style wrapperStyle = wrapper.getElement().getStyle(); Style widgetStyle = wrapper.getWidget().getElement().getStyle(); + // Ensure previous heights do not affect the measures + wrapperStyle.clearWidth(); + if (widgetStyle.getWidth() != null && widgetStyle.getWidth().endsWith("%")) { int w; @@ -398,8 +403,6 @@ public class VAbsoluteLayout extends ComplexPanel { - wrapper.getElement().getOffsetLeft(); } wrapperStyle.setWidth(w, Unit.PX); - } else { - wrapperStyle.clearWidth(); } wrapper.updateCaptionPosition(); diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.html b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.html new file mode 100644 index 0000000000..01206b317c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.html @@ -0,0 +1,37 @@ + + + + + + +New Test + + + + + + + + + + + + + + + + + + + + + + + + + + + +
New Test
open/run/com.vaadin.tests.components.absolutelayout.AbsoluteLayoutResizing?restartApplication
dragAndDropvaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutResizing::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VSplitPanelVertical[0]/domChild[0]/domChild[1]/domChild[0]0,294
dragAndDropvaadin=runcomvaadintestscomponentsabsolutelayoutAbsoluteLayoutResizing::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VSplitPanelVertical[0]/VSplitPanelHorizontal[0]/domChild[0]/domChild[1]/domChild[0]588,0
screenCaptureresized
+ + diff --git a/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.java b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.java new file mode 100644 index 0000000000..810a583ba5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/absolutelayout/AbsoluteLayoutResizing.java @@ -0,0 +1,44 @@ +package com.vaadin.tests.components.absolutelayout; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.AbsoluteLayout; +import com.vaadin.ui.HorizontalSplitPanel; +import com.vaadin.ui.TextArea; +import com.vaadin.ui.VerticalSplitPanel; + +public class AbsoluteLayoutResizing extends TestBase { + + @Override + protected void setup() { + getLayout().setSizeFull(); + + AbsoluteLayout al = new AbsoluteLayout(); + + TextArea ta = new TextArea(); + ta.setValue("When resizing the layout this text area should also get resized"); + ta.setSizeFull(); + al.addComponent(ta, "left: 10px; right: 10px; top: 10px; bottom: 10px;"); + + HorizontalSplitPanel horizPanel = new HorizontalSplitPanel(); + horizPanel.setSizeFull(); + horizPanel.setFirstComponent(al); + + VerticalSplitPanel vertPanel = new VerticalSplitPanel(); + vertPanel.setSizeFull(); + vertPanel.setFirstComponent(horizPanel); + + addComponent(vertPanel); + + } + + @Override + protected String getDescription() { + return "Absolute layout should correctly dynamically resize itself"; + } + + @Override + protected Integer getTicketNumber() { + return 10427; + } + +} -- 2.39.5