Skip to content

Commit 32bc2e9

Browse files
author
Gabriel Schulhof
committed
Select: Unwind stack before blur()ing in response to change
Closes jquery-archivegh-7723 Fixes jquery-archivegh-7685
1 parent 59fac36 commit 32bc2e9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

js/widgets/forms/select.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ $.widget( "mobile.selectmenu", $.extend( {
143143
self.refresh();
144144

145145
if ( !!options.nativeMenu ) {
146-
this.blur();
146+
self._delay( function() {
147+
self.select.blur();
148+
});
147149
}
148150
});
149151

tests/unit/select/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
<option value="3">The 3rd Option</option>
5151
<option value="4">The 4th Option</option>
5252
</select>
53+
<select id="blur-test">
54+
<option value="1">Option 1</option>
55+
<option value="2">Option 2</option>
56+
</select>
5357
</div>
5458
</div>
5559
</body>

tests/unit/select/select_core.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
(function($){
66

7+
module( "Native select" );
8+
9+
test( "Native select does not blur synchronously in response to change", function() {
10+
var selectmenu = $( "#blur-test" );
11+
12+
selectmenu.focus();
13+
14+
selectmenu.trigger( "change" );
15+
16+
deepEqual( selectmenu.parent().hasClass( "ui-focus" ), true,
17+
"Native select is focused after triggering 'change'" );
18+
});
19+
720
module( "Custom select" );
821

922
test( "Custom select is enhanced correctly", function() {

0 commit comments

Comments
 (0)