]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes #3884: Menubar with collapsed menus does not handle resize events properly
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Fri, 18 Dec 2009 07:52:57 +0000 (07:52 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Fri, 18 Dec 2009 07:52:57 +0000 (07:52 +0000)
Fixes #3881: MenuBar collapsing slightly broken with Reindeer theme

svn changeset:10408/svn branch:6.2

src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java

index d985aa062657091778d7768b338923c9bde173e9..43ba72dc82d1329b6d9f613d064e893f125eb9ee 100644 (file)
@@ -86,6 +86,9 @@ public class VMenuBar extends Widget implements Paintable,
     @Override
     public void setWidth(String width) {
         Util.setWidthExcludingPaddingAndBorder(this, width, 0);
+        hideChildren();
+        setSelected(null);
+        menuVisible = false;
     }
 
     /**
@@ -755,6 +758,7 @@ public class VMenuBar extends Widget implements Paintable,
     /**
      * @author Jouni Koivuviita / IT Mill Ltd.
      */
+    private int paddingWidth = -1;
 
     public void iLayout() {
         // Only collapse if there is more than one item in the root menu and the
@@ -773,7 +777,13 @@ public class VMenuBar extends Widget implements Paintable,
             }
 
             // Measure available space
-            int availableWidth = getElement().getClientWidth();
+            if (paddingWidth == -1) {
+                int widthBefore = getElement().getClientWidth();
+                getElement().getStyle().setProperty("padding", "0");
+                paddingWidth = widthBefore - getElement().getClientWidth();
+                getElement().getStyle().setProperty("padding", "");
+            }
+            int availableWidth = getElement().getClientWidth() - paddingWidth;
             int diff = availableWidth - getConsumedWidth();
 
             removeItem(moreItem);