Skip to content

Commit d1505e3

Browse files
committed
Dialog: Move call to _focusTabbable and triggering of open and focus events into the _show callback. Fixes #6756 - Dialog: show: "blind" with link in content doesn't animate properly. Fixes #8051 - Dialog: 'Explode' dialog animation causes crash in IE 6, 7 and 8. Fixes #4421 - Dialog: Focus lost from dialog which uses show-effect
1 parent ceebe07 commit d1505e3

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

tests/unit/dialog/dialog.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"ui/jquery.ui.resizable.js",
2525
"ui/jquery.ui.button.js",
2626
"ui/jquery.ui.effect.js",
27+
"ui/jquery.ui.effect-blind.js",
2728
"ui/jquery.ui.effect-clip.js",
29+
"ui/jquery.ui.effect-explode.js",
2830
"ui/jquery.ui.dialog.js"
2931
]
3032
});

tests/unit/dialog/dialog_options.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,4 +531,44 @@ test("#4826: setting resizable false toggles resizable on dialog", function() {
531531

532532
});
533533

534+
asyncTest( "#8051 - 'Explode' dialog animation causes crash in IE 6, 7 and 8", function() {
535+
expect( 1 );
536+
var el = $( "<div></div>" ).dialog({
537+
show: "explode",
538+
focus: function() {
539+
ok( true, "dialog opened with animation" );
540+
el.remove();
541+
start();
542+
}
543+
});
544+
});
545+
546+
asyncTest( "#4421 - Focus lost from dialog which uses show-effect", function() {
547+
expect( 1 );
548+
var el = $( "<div></div>" ).dialog({
549+
show: "blind",
550+
focus: function() {
551+
equal( el.dialog( "widget" ).find( ":focus" ).length, 1, "dialog maintains focus" );
552+
el.remove();
553+
start();
554+
}
555+
});
556+
});
557+
558+
asyncTest( "Open followed by close during show effect", function() {
559+
expect( 1 );
560+
var el = $( "<div></div>" ).dialog({
561+
show: "blind",
562+
close: function() {
563+
ok( true, "dialog closed properly during animation" );
564+
el.remove();
565+
start();
566+
}
567+
});
568+
569+
setTimeout( function() {
570+
el.dialog("close");
571+
}, 100 );
572+
});
573+
534574
})(jQuery);

ui/jquery.ui.dialog.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ $.widget( "ui.dialog", {
207207
},
208208

209209
open: function() {
210+
var that = this;
210211
if ( this._isOpen ) {
211212
if ( this._moveToTop() ) {
212213
this._focusTabbable();
@@ -220,13 +221,13 @@ $.widget( "ui.dialog", {
220221
this._position();
221222
this._createOverlay();
222223
this._moveToTop( null, true );
223-
this._show( this.uiDialog, this.options.show );
224-
225-
this._focusTabbable();
224+
this._show( this.uiDialog, this.options.show, function() {
225+
that._focusTabbable();
226+
that._trigger("focus");
227+
});
226228

227229
this._isOpen = true;
228230
this._trigger("open");
229-
this._trigger("focus");
230231
},
231232

232233
_focusTabbable: function() {

0 commit comments

Comments
 (0)