Fix for HeaderPanel hidden widgets when set again.
This fixes the bug on the HeaderPanel when a header, content or footer
widget is set again it will become hidden. This is caused because the
container elements in the HeaderPanel in which the widgets are set will
get display none because the add calls remove, and remove hides it as part
of the remove. In the setters before the call to add specific the container
is made visible but the bug is that the add hides it via the remove. Which
is only triggered if the current widget is null (and remove is not called).
This fix moves the call from before the add, to after the remove (in the add)
to make sure it is made visible as expected. To be complete it only makes
the containers visible if the new widget passed is not null.
Bug: issue 7037
Change-Id: I2b41970c37112db257089dc648534de1f257fc00
diff --git a/user/src/com/google/gwt/user/client/ui/HeaderPanel.java b/user/src/com/google/gwt/user/client/ui/HeaderPanel.java
index 1a268d3..e64bd47 100644
--- a/user/src/com/google/gwt/user/client/ui/HeaderPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/HeaderPanel.java
@@ -216,7 +216,6 @@
* @param w the widget to use as the content
*/
public void setContentWidget(Widget w) {
- contentContainer.getStyle().clearDisplay();
add(w, content, contentContainer);
// Logical attach.
@@ -230,7 +229,6 @@
* @param w the widget to use as the footer
*/
public void setFooterWidget(Widget w) {
- footerContainer.getStyle().clearDisplay();
add(w, footer, footerContainer);
// Logical attach.
@@ -244,7 +242,6 @@
* @param w the widget to use as the header
*/
public void setHeaderWidget(Widget w) {
- headerContainer.getStyle().clearDisplay();
add(w, header, headerContainer);
// Logical attach.
@@ -279,6 +276,7 @@
if (w != null) {
// Physical attach.
container.appendChild(w.getElement());
+ container.getStyle().clearDisplay();
adopt(w);
}
diff --git a/user/test/com/google/gwt/user/client/ui/HeaderPanelTest.java b/user/test/com/google/gwt/user/client/ui/HeaderPanelTest.java
index d2eb1d6..dc237ee 100644
--- a/user/test/com/google/gwt/user/client/ui/HeaderPanelTest.java
+++ b/user/test/com/google/gwt/user/client/ui/HeaderPanelTest.java
@@ -214,6 +214,12 @@
panel.setContentWidget(widget);
assertEquals(widget, panel.getContentWidget());
+ // Test for issue 7037
+ widget = new Label("hello world 2");
+ panel.setContentWidget(widget);
+ assertTrue("Issue 7037", UIObject.isVisible(
+ panel.getContentWidget().getElement().getParentElement()));
+
panel.remove(widget);
assertNull(panel.getContentWidget());
}