Skip to content

Commit

Permalink
Menubar: Fix closing with escape key
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaefferer committed Mar 17, 2011
1 parent 133137b commit 24d1952
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/visual/menu/menubar.js
Expand Up @@ -50,13 +50,17 @@ $.widget("ui.menubar", {
menu = input.next("ul");

input.bind("click focus mouseenter", function(event) {
// ignore triggered focus event
if (event.type == "focus" && !event.originalEvent) {
return;
}
event.preventDefault();
event.stopPropagation();
if (menu.is(":visible") && self.active && self.active[0] == menu[0]) {
self._close();
return;
}
if (menu.length && (self.open || event.type == "click")) {
if (self.open || event.type == "click") {
self._open(event, menu);
}
})
Expand Down Expand Up @@ -98,11 +102,11 @@ $.widget("ui.menubar", {
})
self._bind({
keyup: function(event) {
if (event.keyCode == $.ui.keyCode.ESCAPE) {
if (event.keyCode == $.ui.keyCode.ESCAPE && self.open) {
if (self.active.menu("left", event) !== true) {
self._close( event );
// bypass the focus event handler above
self.active.prev()[0].focus();
var active = self.active;
self.active.blur();
active.prev().focus();
}
}
}
Expand Down

0 comments on commit 24d1952

Please sign in to comment.