aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkborchers <kris.borchers@gmail.com>2012-04-16 23:30:33 -0500
committerkborchers <kris.borchers@gmail.com>2012-04-16 23:30:33 -0500
commit1ce42f4328167826e9868ee1bf21f96317927dec (patch)
tree233d64893906578989fe592a8d329a06f5554835
parentfac809f9e5e30cb46053710970fb2a0e855ce9e1 (diff)
downloadjquery-ui-1ce42f4328167826e9868ee1bf21f96317927dec.tar.gz
jquery-ui-1ce42f4328167826e9868ee1bf21f96317927dec.zip
Menu: Modified interactions to allow keyboard navigation to disabled items so that they are announced by screen readers but prevent selection of and navigation to sub-menus of disabled items
-rw-r--r--tests/visual/menu/menu.html2
-rw-r--r--ui/jquery.ui.menu.js30
2 files changed, 14 insertions, 18 deletions
diff --git a/tests/visual/menu/menu.html b/tests/visual/menu/menu.html
index d67083663..e62e18ae5 100644
--- a/tests/visual/menu/menu.html
+++ b/tests/visual/menu/menu.html
@@ -118,7 +118,7 @@
<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>
+ <li class="ui-state-disabled">
<a href="#">Delphi</a>
<ul>
<li><a href="#">Ada</a></li>
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index dd099395d..0e70f6774 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -99,7 +99,7 @@ $.widget( "ui.menu", {
"mouseleave .ui-menu": "collapseAll",
"focus": function( event ) {
var menu = this.element,
- firstItem = menu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).eq( 0 );
+ firstItem = menu.children( ".ui-menu-item" ).eq( 0 );
if ( this._hasScroll() && !this.active ) {
menu.children().each(function() {
var currentItem = $( this );
@@ -196,15 +196,17 @@ $.widget( "ui.menu", {
event.preventDefault();
break;
case $.ui.keyCode.RIGHT:
- this.expand( event );
+ !this.active.is(".ui-state-disabled") && this.expand( event );
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
- if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
- this.expand( event );
- }
- else {
- this.select( event );
+ if ( !this.active.is(".ui-state-disabled") ) {
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ }
+ else {
+ this.select( event );
+ }
}
event.preventDefault();
break;
@@ -442,7 +444,6 @@ $.widget( "ui.menu", {
this.active
.children( ".ui-menu " )
.children( ".ui-menu-item" )
- .not( ".ui-state-disabled" )
.first();
if ( newItem && newItem.length ) {
@@ -478,12 +479,10 @@ $.widget( "ui.menu", {
if ( direction === "first" || direction === "last" ) {
next = this.active
[ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
- .not( ".ui-state-disabled" )
.eq( -1 );
} else {
next = this.active
[ direction + "All" ]( ".ui-menu-item" )
- .not( ".ui-state-disabled" )
.eq( 0 );
}
}
@@ -492,9 +491,6 @@ $.widget( "ui.menu", {
}
this.focus( event, next );
- if ( next.is( ".ui-state-disabled" ) ) {
- this._move( direction, filter, event );
- }
},
nextPage: function( event ) {
@@ -509,14 +505,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.nextAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each(function() {
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $( this ).offset().top - base - height < 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" )
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
[ !this.active ? "first" : "last" ]() );
}
},
@@ -533,14 +529,14 @@ $.widget( "ui.menu", {
var base = this.active.offset().top,
height = this.element.height(),
result;
- this.active.prevAll( ".ui-menu-item" ).not( ".ui-state-disabled" ).each(function() {
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
result = $( this );
return $(this).offset().top - base + height > 0;
});
this.focus( event, result );
} else {
- this.focus( event, this.activeMenu.children( ".ui-menu-item" ).not( ".ui-state-disabled" ).first() );
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
}
},