Skip to content
Permalink
Browse files

Selectmenu: re-enabled lazy loading of the menu items (menu refresh)

  • Loading branch information...
fnagel committed Feb 21, 2012
1 parent d0c31c1 commit 52e43c076fc92c88d7a5ea5f101e7d7a9922afea
@@ -8,8 +8,10 @@ test("accessibility", function () {
menu = element.selectmenu("menuWidget").parent(),
link = button.find("a"),
selected = element.find("option:selected"),
ul = menu.children("ul"),
links = ul.find("li.ui-menu-item a");
ul = menu.children("ul");

link.simulate( "focus" );
var links = ul.find("li.ui-menu-item a");

expect(12 + links.length * 2);

@@ -51,9 +53,11 @@ $.each([
menu = element.selectmenu("menuWidget").parent(),
link = button.find("a"),
ul = menu.children("ul"),
links = ul.find("li.ui-menu-item a"),
selected = element.find("option:selected");

link.simulate( "focus" )
var links = ul.find("li.ui-menu-item a");

link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equals( ul.attr("aria-activedescendant"), links.eq(element[0].selectedIndex).attr("id"), "after keydown menu aria-activedescendant" );
equals( links.eq(element[0].selectedIndex).attr("aria-selected"), "true", "after keydown selected menu link aria-selected" );
@@ -23,7 +23,7 @@ test("change", function () {
menu = this.element.selectmenu("menuWidget").parent(),
value = this.element.find("option").first().text();

button.find("a").simulate( "click" );
button.find("a").simulate( "focus" ).simulate( "click" );
menu.find("a").first().simulate( "mouseover" ).trigger( "click" );
});

@@ -63,7 +63,7 @@ test("focus", function () {
var button = this.element.selectmenu("widget").parent(),
menu = this.element.selectmenu("menuWidget").parent();

button.find("a").simulate( "click" );
button.find("a").simulate( "focus" ).simulate( "click" );
menu.find(".ui-menu-item").simulate("mouseover");
});

@@ -98,7 +98,7 @@ test("select", function () {
var button = this.element.selectmenu("widget").parent(),
menu = this.element.selectmenu("menuWidget").parent();

button.find("a").simulate( "click" );
button.find("a").simulate( "focus" ).simulate( "click" );
menu.find("a").first().simulate( "mouseover" ).trigger("click");
});

@@ -54,7 +54,6 @@ $.widget( "ui.selectmenu", {
this._bind( this.button, this._buttonEvents );

this._drawMenu();
this.refresh();

if ( this.options.disabled ) {
this.disable();
@@ -70,7 +69,7 @@ $.widget( "ui.selectmenu", {
// create button
this.button = $( '<a />', {
href: '#' + this.ids.id,
html: '&nbsp;',
html: this.element.find( "option:selected" ).text() || '&nbsp;',
tabindex: ( tabindex ? tabindex : this.options.disabled ? -1 : 0 ),
id: this.ids.button,
width: this.element.outerWidth(),
@@ -316,6 +315,11 @@ $.widget( "ui.selectmenu", {
},

_buttonEvents: {
focus: function( event ) {
// init Menu on first focus
this.refresh();
this.button.unbind( "focus." + this.widgetName );
},
click: function( event ) {
this._toggle( event );
event.preventDefault();
@@ -389,7 +393,7 @@ $.widget( "ui.selectmenu", {
_setSelected: function( item ) {
var link = this._getSelectedItem().find("a");
// update button text
this.button.button( "option", "label", item.label );
this.button.find( "span.ui-button-text" ).html( item.label );
// change ARIA attr
this.button.add( this.menu ).attr( "aria-activedescendant" , link.attr( "id" ) );
this.menuItems.find("a").attr( "aria-selected", false );

0 comments on commit 52e43c0

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