From 58b730f7c7a2fa848eeab12c5b26736a102ed1a4 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Mon, 28 Feb 2011 22:53:06 +0100 Subject: [PATCH] Menubar: Close menu on input click when already open --- tests/visual/menu/menubar.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index 57d9ee5de..afddd76a6 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -49,13 +49,16 @@ $.widget("ui.menubar", { var input = $(this), menu = input.next("ul"); - input - .bind("click focus mouseenter", function(event) { + input.bind("click focus mouseenter", function(event) { + event.preventDefault(); + event.stopPropagation(); + if (menu.is(":visible") && self.active && self.active[0] == menu[0]) { + self._close(); + return; + } if (menu.length && (!/^mouse/.test(event.type) || self.active && self.active.is(":visible") )) { self._open(event, menu); } - event.preventDefault(); - event.stopPropagation(); }) .addClass("ui-button ui-widget ui-button-text-only ui-menubar-link") .wrapInner(""); -- 2.39.5