Skip to content
Permalink
Browse files

Menu: Prevent clicking on disabled menu items and remove unnecessary …

…extra padding from disabled items.
  • Loading branch information...
kborchers committed Feb 3, 2012
1 parent 4259978 commit 48ad0994a0e517ac22c4fccab0958b6668640d78
Showing with 17 additions and 13 deletions.
  1. +5 −5 tests/visual/menu/menu.html
  2. +1 −1 themes/base/jquery.ui.menu.css
  3. +11 −7 ui/jquery.ui.menu.js
@@ -76,12 +76,12 @@
<ul id="menu2">
<li><a href="#">Aberdeen</a></li>
<li><a href="#">Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li class="ui-state-disabled"><a href="#">Adamsville</a></li>
<li><a href="#">Addyston</a></li>
<li>
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
<li class="ui-state-disabled"><a href="#">Ada</a></li>
<li><a href="#">Saarland</a></li>
<li><a href="#">Salzburg</a></li>
</ul>
@@ -113,7 +113,7 @@

<ul id="menu3">
<li><a href="#"><span class="ui-icon ui-icon-print"></span>Aberdeen</a></li>
<li><a href="#"><span class="ui-icon ui-icon-scissors"></span>Ada</a></li>
<li class="ui-state-disabled"><a href="#"><span class="ui-icon ui-icon-scissors"></span>Ada</a></li>
<li><a href="#">Adamsville</a></li>
<li><a href="#"><span class="ui-icon ui-icon-wrench"></span>Addyston</a></li>
<li>
@@ -193,7 +193,7 @@
<div id="menu5">
<blockquote><a href="#">Aberdeen</a></blockquote>
<blockquote><a href="#">Ada</a></blockquote>
<blockquote><a href="#">Adamsville</a></blockquote>
<blockquote class="ui-state-disabled"><a href="#">Adamsville</a></blockquote>
<blockquote><a href="#">Addyston</a></blockquote>
<blockquote>
<a href="#">Delphi</a>
@@ -243,7 +243,7 @@
<span class="address-content">Bloomsburg, PA 12345</span>
</a>
</div>
<div class="address-item">
<div class="address-item ui-state-disabled">
<a href="#">
<span class="address-header">James Doe</span>
<span class="address-content">78 West Main St Apt 3A</span>
@@ -14,7 +14,7 @@
.ui-menu .ui-menu-item a.ui-state-focus,
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }

.ui-menu .ui-state-disabled { font-weight: normal; padding: .0em .4em; margin: .4em 0 .2em; line-height: 1.5; }
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }

/* icon support */
.ui-menu-icons { position: relative; }
@@ -56,13 +56,17 @@ $.widget( "ui.menu", {
},
"click .ui-menu-item:has(a)": function( event ) {
event.stopImmediatePropagation();
this.select( event );
// Redirect focus to the menu with a delay for firefox
this._delay( function() {
if ( !this.element.is(":focus") ) {
this.element.focus();
}
}, 20);
//Don't select disabled menu items
if ( !$( event.target ).closest( ".ui-menu-item" ).is( ".ui-state-disabled" ) ) {
console.log(event.target);

This comment has been minimized.

Copy link
@petersendidit

petersendidit Feb 4, 2012

Member

Looks like some debugging got left in the commit.

This comment has been minimized.

Copy link
@kborchers

kborchers Feb 4, 2012

Author Member

Thanks for catching this. Fixing it now.

this.select( event );
// Redirect focus to the menu with a delay for firefox
this._delay( function() {
if ( !this.element.is(":focus") ) {
this.element.focus();
}
}, 20);
}
},
"mouseover .ui-menu-item": function( event ) {
event.stopImmediatePropagation();

0 comments on commit 48ad099

Please sign in to comment.
You can’t perform that action at this time.