]> source.dussan.org Git - jquery-ui.git/commitdiff
Fix "menubar does not collapse when clicking on other menubar" + minor changes
authorHans Hillen <hans.hillen@gmail.com>
Mon, 18 Apr 2011 21:05:50 +0000 (23:05 +0200)
committerHans Hillen <hans.hillen@gmail.com>
Mon, 18 Apr 2011 21:05:50 +0000 (23:05 +0200)
tests/visual/menu/menubar.html
tests/visual/menu/menubar.js
ui/jquery.ui.menu.js

index c5b63ae86a19f3c3174ede6e5424a2070f4b3d48..1b4b331f610c835f7eed306f87c79584c489ddd4 100644 (file)
                .ui-menubar .ui-button { float: left; font-weight: normal; border-top-width: 0 !important; border-bottom-width: 0 !important; margin: 0; outline: none; }
                .ui-menubar .ui-menubar-link { border-right: 1px dashed transparent; border-left: 1px dashed transparent; }
                
-               ol.ui-menubar, ul.ui-menubar {
+               .ui-menubar, .ui-menubar {
                        list-style: none;
                        margin-left: 0;
                        padding-left: 0;        
                }
                
-               li.ui-menubar-item {
+               .ui-menubar-item {
                        float: left;            
                }
                
index 453f5fae795ec61bd44801fcf70068cdea66d466..e6f6ab069a3e4d537b38b51b0268c120da3bdc51 100644 (file)
@@ -67,7 +67,6 @@ $.widget("ui.menubar", {
                                        return;
                                }
                                event.preventDefault();
-                               event.stopPropagation();
                                if (event.type == "click" && menu.is(":visible") && self.active && self.active[0] == menu[0]) {
                                        self._close();
                                        return;
@@ -111,8 +110,11 @@ $.widget("ui.menubar", {
                });
                self._bind(document, {
                        click: function(event) {
-                               if (self.open && !$(event.target).closest(".ui-menubar").length) {
-                                       self._close();
+                               if (self.open) {
+                                       var menubar = $(event.target).closest(".ui-menubar");
+                                       if (!menubar.length || menubar.get(0) !== self.element.get(0)) {
+                                               self._close();
+                                       }
                                }
                        }
                })
@@ -162,6 +164,8 @@ $.widget("ui.menubar", {
        },
        
        _close: function() {
+               if (!this.active || !this.active.length)
+                       return;
                this.active.menu("closeAll").hide().attr("aria-hidden", "true").attr("aria-expanded", "false");
                this.active.prev().removeClass("ui-state-active").removeAttr("tabIndex");
                this.active = null;
index 0b2852f06e40d3fc5b548d143d44c0e916f8113f..0a06fe0b5bafa44c9e94ded7f311b38899c72da1 100644 (file)
@@ -319,6 +319,7 @@ $.widget("ui.menu", {
                if (newItem && newItem.length) {
                        this._open(newItem.parent());
                        var current = this.active;
+                       //timeout so Firefox will not hide activedescendant change in expanding submenu from AT
                        setTimeout(function(){self.focus(event, newItem)}, 20);
                        return true;
                }