Skip to content
Browse files

Selectmenu: revert initial refresh method changes (with unit tests)

This reverts commit 27049fc and d83e169
  • Loading branch information...
1 parent d83e169 commit 725023e30db10cc0a3ec2b8b9fda0ec80a4ab496 @fnagel fnagel committed Jan 22, 2012
View
1 tests/unit/selectmenu/selectmenu_core.js
@@ -53,7 +53,6 @@ $.each([
equals( button.text(), selected.text(), "inital button text" );
- link.simulate( "focus" );
link.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
equals( element.find("option:selected").val(), selected.next("option").val() , "after keydown original select state" );
equals( button.text(), selected.next("option").text(), "after keydown button text" );
View
24 tests/unit/selectmenu/selectmenu_events.js
@@ -22,11 +22,9 @@ test("change", function () {
var widget = this.element.selectmenu("widget"),
menu = widget.filter(".ui-selectmenu-menu"),
button = widget.filter(".ui-selectmenu-button"),
- link = button.find("a"),
value = this.element.find("option").first().text();
-
- link.simulate( "focus" );
- link.simulate( "click" );
+
+ button.find("a").simulate( "click" );
menu.find("a").first().simulate( "mouseover" ).simulate( "click" );
});
@@ -42,11 +40,6 @@ test("close", function () {
}
});
- var widget = this.element.selectmenu("widget"),
- button = widget.filter(".ui-selectmenu-button"),
- link = button.find("a");
-
- link.simulate( "focus" );
this.element.selectmenu("open").selectmenu("close");
});
@@ -70,11 +63,9 @@ test("focus", function () {
var widget = this.element.selectmenu("widget"),
button = widget.filter(".ui-selectmenu-button"),
- link = button.find("a"),
menu = widget.filter(".ui-selectmenu-menu");
- link.simulate( "focus" );
- link.simulate( "click" );
+ button.find("a").simulate( "click" );
menu.find(".ui-menu-item").simulate("mouseover");
});
@@ -90,11 +81,6 @@ test("open", function () {
}
});
- var widget = this.element.selectmenu("widget"),
- button = widget.filter(".ui-selectmenu-button"),
- link = button.find("a");
-
- link.simulate( "focus" );
this.element.selectmenu("open");
});
@@ -113,11 +99,9 @@ test("select", function () {
var widget = this.element.selectmenu("widget"),
button = widget.filter(".ui-selectmenu-button"),
- link = button.find("a"),
menu = widget.filter(".ui-selectmenu-menu");
- link.simulate( "focus" );
- link.simulate( "click" );
+ button.find("a").simulate( "click" );
menu.find("a").first().simulate( "mouseover" ).simulate("click");
});
View
1 tests/unit/selectmenu/selectmenu_options.js
@@ -23,7 +23,6 @@ test("dropdown: CSS styles", function () {
menu = widget.filter(".ui-selectmenu-menu"),
ul = widget.find("ul");
- link.simulate( "focus" );
this.element.selectmenu("open");
ok( link.hasClass("ui-corner-top") && !link.hasClass("ui-corner-all"), "button styles dropdown");
ok( ul.hasClass("ui-corner-bottom") && !ul.hasClass("ui-corner-all"), "menu styles dropdown");
View
16 ui/jquery.ui.selectmenu.js
@@ -185,6 +185,12 @@ $.widget( "ui.selectmenu", {
open: function( event ) {
if ( !this.options.disabled ) {
+ // init menu when initial opened
+ if ( !this.wasOpen ) {
+ this.refresh();
+ this.wasOpen = true;
+ }
+
var currentItem = this._getSelectedItem();
this._toggleButtonStyle();
@@ -269,6 +275,11 @@ $.widget( "ui.selectmenu", {
},
_move: function( direction, event ) {
+ // init menu when not done yet
+ if ( !this.wasOpen ) {
+ this.refresh();
+ this.wasOpen = true;
+ }
if ( direction == "first" || direction == "last" ) {
// set focus manually for first or last item
this.menu.menu( "focus", event, this.menu.find( "li" ).not( '.ui-selectmenu-optgroup' )[ direction ]() );
@@ -300,11 +311,6 @@ $.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();

0 comments on commit 725023e

Please sign in to comment.
Something went wrong with that request. Please try again.