Skip to content

Commit b539e2e

Browse files
committed
Merge branch 'master' into selectmenu
2 parents 53ea933 + afdc577 commit b539e2e

File tree

7 files changed

+116
-31
lines changed

7 files changed

+116
-31
lines changed

tests/unit/autocomplete/autocomplete_core.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,90 @@ test( "allow form submit on enter when menu is not active", function() {
8080
ok( !event.isDefaultPrevented(), "default action is prevented" );
8181
});
8282

83+
(function() {
84+
test( "up arrow invokes search - input", function() {
85+
arrowsInvokeSearch( "#autocomplete", true, true );
86+
});
87+
88+
test( "down arrow invokes search - input", function() {
89+
arrowsInvokeSearch( "#autocomplete", false, true );
90+
});
91+
92+
test( "up arrow invokes search - textarea", function() {
93+
arrowsInvokeSearch( "#autocomplete-textarea", true, false );
94+
});
95+
96+
test( "down arrow invokes search - textarea", function() {
97+
arrowsInvokeSearch( "#autocomplete-textarea", false, false );
98+
});
99+
100+
test( "up arrow invokes search - contenteditable", function() {
101+
arrowsInvokeSearch( "#autocomplete-contenteditable", true, false );
102+
});
103+
104+
test( "down arrow invokes search - contenteditable", function() {
105+
arrowsInvokeSearch( "#autocomplete-contenteditable", false, false );
106+
});
107+
108+
test( "up arrow moves focus - input", function() {
109+
arrowsMoveFocus( "#autocomplete", true );
110+
});
111+
112+
test( "down arrow moves focus - input", function() {
113+
arrowsMoveFocus( "#autocomplete", false );
114+
});
115+
116+
test( "up arrow moves focus - textarea", function() {
117+
arrowsMoveFocus( "#autocomplete-textarea", true );
118+
});
119+
120+
test( "down arrow moves focus - textarea", function() {
121+
arrowsMoveFocus( "#autocomplete-textarea", false );
122+
});
123+
124+
test( "up arrow moves focus - contenteditable", function() {
125+
arrowsMoveFocus( "#autocomplete-contenteditable", true );
126+
});
127+
128+
test( "down arrow moves focus - contenteditable", function() {
129+
arrowsMoveFocus( "#autocomplete-contenteditable", false );
130+
});
131+
132+
function arrowsInvokeSearch( id, isKeyUp, shouldMove ) {
133+
expect( 1 );
134+
135+
var didMove = false,
136+
element = $( id ).autocomplete({
137+
source: [ "a" ],
138+
delay: 0,
139+
minLength: 0
140+
});
141+
element.data( "autocomplete" )._move = function() {
142+
didMove = true;
143+
};
144+
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
145+
equal( didMove, shouldMove, "respond to arrow" );
146+
}
147+
148+
function arrowsMoveFocus( id, isKeyUp ) {
149+
expect( 1 );
150+
151+
var didMove = false,
152+
element = $( id ).autocomplete({
153+
source: [ "a" ],
154+
delay: 0,
155+
minLength: 0
156+
});
157+
element.data( "autocomplete" )._move = function() {
158+
ok( true, "repsond to arrow" );
159+
};
160+
element.autocomplete( "search" );
161+
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
162+
}
163+
})();
164+
165+
(function() {
166+
167+
})();
168+
83169
}( jQuery ) );

tests/unit/dialog/dialog_options.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,24 @@ test("draggable", function() {
177177
});
178178

179179
test("height", function() {
180-
expect(3);
180+
expect(4);
181181

182182
el = $('<div></div>').dialog();
183-
equals(dlg().height(), 150, "default height");
183+
equals(dlg().outerHeight(), 150, "default height");
184184
el.remove();
185185

186186
el = $('<div></div>').dialog({ height: 237 });
187-
equals(dlg().height(), 237, "explicit height");
187+
equals(dlg().outerHeight(), 237, "explicit height");
188188
el.remove();
189189

190190
el = $('<div></div>').dialog();
191191
el.dialog('option', 'height', 238);
192-
equals(dlg().height(), 238, "explicit height set after init");
192+
equals(dlg().outerHeight(), 238, "explicit height set after init");
193+
el.remove();
194+
195+
el = $('<div></div>').css("padding", "20px")
196+
.dialog({ height: 240 });
197+
equals(dlg().outerHeight(), 240, "explicit height with padding");
193198
el.remove();
194199
});
195200

themes/base/jquery.ui.button.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* http://docs.jquery.com/UI/Button#theming
99
*/
10-
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
10+
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: hidden; *overflow: visible; } /* the overflow property removes extra width in IE */
1111
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
1212
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
1313
.ui-button-icons-only { width: 3.4em; }

themes/base/jquery.ui.dialog.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
1111
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
12-
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
12+
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
1313
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
1414
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
1515
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }

ui/jquery.ui.autocomplete.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ $.widget( "ui.autocomplete", {
5858
suppressKeyPressRepeat,
5959
suppressInput;
6060

61+
this.isMultiLine = this.element.is( "textarea,[contenteditable]" );
6162
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
6263

6364
this.element
@@ -92,15 +93,11 @@ $.widget( "ui.autocomplete", {
9293
break;
9394
case keyCode.UP:
9495
suppressKeyPress = true;
95-
self._move( "previous", event );
96-
// prevent moving cursor to beginning of text field in some browsers
97-
event.preventDefault();
96+
self._keyEvent( "previous", event );
9897
break;
9998
case keyCode.DOWN:
10099
suppressKeyPress = true;
101-
self._move( "next", event );
102-
// prevent moving cursor to end of text field in some browsers
103-
event.preventDefault();
100+
self._keyEvent( "next", event );
104101
break;
105102
case keyCode.ENTER:
106103
case keyCode.NUMPAD_ENTER:
@@ -151,14 +148,10 @@ $.widget( "ui.autocomplete", {
151148
self._move( "nextPage", event );
152149
break;
153150
case keyCode.UP:
154-
self._move( "previous", event );
155-
// prevent moving cursor to beginning of text field in some browsers
156-
event.preventDefault();
151+
self._keyEvent( "previous", event );
157152
break;
158153
case keyCode.DOWN:
159-
self._move( "next", event );
160-
// prevent moving cursor to end of text field in some browsers
161-
event.preventDefault();
154+
self._keyEvent( "next", event );
162155
break;
163156
}
164157
})
@@ -495,6 +488,15 @@ $.widget( "ui.autocomplete", {
495488

496489
_value: function( value ) {
497490
return this.valueMethod.apply( this.element, arguments );
491+
},
492+
493+
_keyEvent: function( keyEvent, event ) {
494+
if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
495+
this._move( keyEvent, event );
496+
497+
// prevents moving cursor to beginning/end of the text field in some browsers
498+
event.preventDefault();
499+
}
498500
}
499501
});
500502

ui/jquery.ui.dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ $.widget("ui.dialog", {
625625
height: "auto",
626626
width: options.width
627627
})
628-
.height();
628+
.outerHeight();
629629
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
630630

631631
if ( options.height === "auto" ) {

ui/jquery.ui.menu.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ $.widget( "ui.menu", {
2929
},
3030
_create: function() {
3131
this.activeMenu = this.element;
32-
this.isScrolling = false;
3332
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
3433
if ( this.element.find( ".ui-icon" ).length ) {
3534
this.element.addClass( "ui-menu-icons" );
@@ -66,13 +65,10 @@ $.widget( "ui.menu", {
6665
},
6766
"mouseover .ui-menu-item": function( event ) {
6867
event.stopImmediatePropagation();
69-
if ( !this.isScrolling ) {
70-
var target = $( event.currentTarget );
71-
// 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
72-
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
73-
this.focus( event, target );
74-
}
75-
this.isScrolling = false;
68+
var target = $( event.currentTarget );
69+
// 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
70+
target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
71+
this.focus( event, target );
7672
},
7773
"mouseleave": "collapseAll",
7874
"mouseleave .ui-menu": "collapseAll",
@@ -86,10 +82,6 @@ $.widget( "ui.menu", {
8682
this.collapseAll( event );
8783
}
8884
}, 0);
89-
},
90-
scroll: function( event ) {
91-
// Keep track of scrolling to prevent mouseover from firing inadvertently when scrolling the menu
92-
this.isScrolling = true;
9385
}
9486
});
9587

0 commit comments

Comments
 (0)