Skip to content

Commit 62cda1f

Browse files
committed
Dialog: Set the _isOpen flag immediately in open(). Fixes #8958 - Dialog: Double ui-widget-overlay when opening modal dialog triggers an event opening same dialog.
1 parent 85dfcdf commit 62cda1f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

tests/unit/dialog/dialog_methods.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,35 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
193193
d1.remove();
194194
});
195195

196+
asyncTest( "#8958: dialog can be opened while opening", function() {
197+
expect( 1 );
198+
199+
var element = $( "<div>" ).dialog({
200+
autoOpen: false,
201+
modal: true,
202+
open: function() {
203+
equal( $( ".ui-widget-overlay" ).length, 1 );
204+
start();
205+
}
206+
});
207+
208+
$( "#favorite-animal" )
209+
// We focus the input to start the test. Once it receives focus, the
210+
// dialog will open. Opening the dialog, will cause an element inside
211+
// the dialog to gain focus, thus blurring the input.
212+
.bind( "focus", function() {
213+
element.dialog( "open" );
214+
})
215+
// When the input blurs, the dialog is in the process of opening. We
216+
// try to open the dialog again, to make sure that dialogs properly
217+
// handle a call to the open() method during the process of the dialog
218+
// being opened.
219+
.bind( "blur", function() {
220+
element.dialog( "open" );
221+
})
222+
.focus();
223+
});
224+
196225
test("#5531: dialog width should be at least minWidth on creation", function () {
197226
expect( 4 );
198227
var element = $("<div></div>").dialog({

ui/jquery.ui.dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ $.widget( "ui.dialog", {
215215
return;
216216
}
217217

218+
this._isOpen = true;
218219
this.opener = $( this.document[0].activeElement );
219220

220221
this._size();
@@ -226,7 +227,6 @@ $.widget( "ui.dialog", {
226227
that._trigger("focus");
227228
});
228229

229-
this._isOpen = true;
230230
this._trigger("open");
231231
},
232232

0 commit comments

Comments
 (0)