mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Selectmenu: revert initial refresh method changes (with unit tests)
This reverts commit27049fc5dc
andd83e169424
This commit is contained in:
parent
d83e169424
commit
725023e30d
@ -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" );
|
||||
|
@ -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");
|
||||
});
|
||||
|
||||
|
@ -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");
|
||||
|
16
ui/jquery.ui.selectmenu.js
vendored
16
ui/jquery.ui.selectmenu.js
vendored
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user