aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/menu.js62
1 files changed, 36 insertions, 26 deletions
diff --git a/ui/menu.js b/ui/menu.js
index 31f621d22..b4909a116 100644
--- a/ui/menu.js
+++ b/ui/menu.js
@@ -36,7 +36,7 @@ return $.widget( "ui.menu", {
items: "> *",
menus: "ul",
position: {
- my: "left-1 top",
+ my: "left top",
at: "right top"
},
role: "menu",
@@ -110,7 +110,8 @@ return $.widget( "ui.menu", {
var target = $( event.currentTarget );
// Remove ui-state-active class from siblings of the newly focused menu item
// to avoid a jump caused by adjacent elements both having a class with a border
- target.siblings( ".ui-state-active" ).removeClass( "ui-state-active" );
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+
this.focus( event, target );
},
mouseleave: "collapseAll",
@@ -169,17 +170,18 @@ return $.widget( "ui.menu", {
.removeClass( "ui-menu-item" )
.removeAttr( "role" )
.removeAttr( "aria-disabled" )
- .removeUniqueId()
- .removeClass( "ui-state-hover" )
- .removeAttr( "tabIndex" )
- .removeAttr( "role" )
- .removeAttr( "aria-haspopup" )
- .children().each( function() {
- var elem = $( this );
- if ( elem.data( "ui-menu-submenu-carat" ) ) {
- elem.remove();
- }
- });
+ .children( ".ui-menu-item-wrapper" )
+ .removeUniqueId()
+ .removeClass( "ui-menu-item-wrapper ui-state-hover" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .children().each(function() {
+ var elem = $( this );
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
+ elem.remove();
+ }
+ });
// Destroy menu dividers
this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
@@ -267,7 +269,7 @@ return $.widget( "ui.menu", {
_activate: function( event ) {
if ( !this.active.is( ".ui-state-disabled" ) ) {
- if ( this.active.is( "[aria-haspopup='true']" ) ) {
+ if ( this.active.children( "[aria-haspopup='true']" ).length ) {
this.expand( event );
} else {
this.select( event );
@@ -294,7 +296,7 @@ return $.widget( "ui.menu", {
})
.each(function() {
var menu = $( this ),
- item = menu.parent(),
+ item = menu.prev(),
submenuCarat = $( "<span>" )
.addClass( "ui-menu-icon ui-icon " + icon )
.data( "ui-menu-submenu-carat", true );
@@ -319,11 +321,14 @@ return $.widget( "ui.menu", {
// Don't refresh list items that are already adapted
items.not( ".ui-menu-item, .ui-menu-divider" )
.addClass( "ui-menu-item" )
- .uniqueId()
- .attr({
- tabIndex: -1,
- role: this._itemRole()
- });
+ .children()
+ .not( ".ui-menu" )
+ .addClass( "ui-menu-item-wrapper" )
+ .uniqueId()
+ .attr({
+ tabIndex: -1,
+ role: this._itemRole()
+ });
// Add aria-disabled attribute to any disabled menu item
items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
@@ -362,7 +367,10 @@ return $.widget( "ui.menu", {
this._scrollIntoView( item );
this.active = item.first();
- focused = this.active.addClass( "ui-state-focus" ).removeClass( "ui-state-active" );
+ focused = this.active.children( ".ui-menu-item-wrapper" )
+ .addClass( "ui-state-focus" )
+ .removeClass( "ui-state-active" );
+
// Only update aria-activedescendant if there's a role
// otherwise we assume focus is managed elsewhere
if ( this.options.role ) {
@@ -372,8 +380,9 @@ return $.widget( "ui.menu", {
// Highlight active parent menu item, if any
this.active
.parent()
- .closest( ".ui-menu-item" )
- .addClass( "ui-state-active" );
+ .closest( ".ui-menu-item" )
+ .children( ".ui-menu-item-wrapper" )
+ .addClass( "ui-state-active" );
if ( event && event.type === "keydown" ) {
this._close();
@@ -419,7 +428,7 @@ return $.widget( "ui.menu", {
return;
}
- this.active.removeClass( "ui-state-focus" );
+ this.active.children( ".ui-menu-item-wrapper" ).removeClass( "ui-state-focus" );
this.active = null;
this._trigger( "blur", event, { item: this.active } );
@@ -628,7 +637,7 @@ return $.widget( "ui.menu", {
this._trigger( "select", event, ui );
},
- _filterMenuItems: function(character) {
+ _filterMenuItems: function( character ) {
var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
regex = new RegExp( "^" + escapedCharacter, "i" );
@@ -638,7 +647,8 @@ return $.widget( "ui.menu", {
// Only match on items, not dividers or other content (#10571)
.filter( ".ui-menu-item" )
.filter(function() {
- return regex.test( $.trim( $( this ).text() ) );
+ return regex.test(
+ $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
});
}
});