]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Set the _isOpen flag immediately in open(). Fixes #8958 - Dialog: Double...
authorScott González <scott.gonzalez@gmail.com>
Thu, 31 Jan 2013 22:20:19 +0000 (17:20 -0500)
committerScott González <scott.gonzalez@gmail.com>
Thu, 31 Jan 2013 22:20:19 +0000 (17:20 -0500)
tests/unit/dialog/dialog_methods.js
ui/jquery.ui.dialog.js

index 2c3495ca261da5d984f9b3f2470f334a39aed447..6de18551373fbd71b7bb66eb288ac57d5c121fe8 100644 (file)
@@ -193,6 +193,35 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() {
        d1.remove();
 });
 
+asyncTest( "#8958: dialog can be opened while opening", function() {
+       expect( 1 );
+
+       var element = $( "<div>" ).dialog({
+               autoOpen: false,
+               modal: true,
+               open: function() {
+                       equal( $( ".ui-widget-overlay" ).length, 1 );
+                       start();
+               }
+       });
+
+       $( "#favorite-animal" )
+               // We focus the input to start the test. Once it receives focus, the
+               // dialog will open. Opening the dialog, will cause an element inside
+               // the dialog to gain focus, thus blurring the input.
+               .bind( "focus", function() {
+                       element.dialog( "open" );
+               })
+               // When the input blurs, the dialog is in the process of opening. We
+               // try to open the dialog again, to make sure that dialogs properly
+               // handle a call to the open() method during the process of the dialog
+               // being opened.
+               .bind( "blur", function() {
+                       element.dialog( "open" );
+               })
+               .focus();
+});
+
 test("#5531: dialog width should be at least minWidth on creation", function () {
        expect( 4 );
        var element = $("<div></div>").dialog({
index 77bf68dd1d59fb65f8710208d24849ee58a4004c..b6ac7aed7b4477e68e4d0dde6ab72392e7ada9cd 100644 (file)
@@ -215,6 +215,7 @@ $.widget( "ui.dialog", {
                        return;
                }
 
+               this._isOpen = true;
                this.opener = $( this.document[0].activeElement );
 
                this._size();
@@ -226,7 +227,6 @@ $.widget( "ui.dialog", {
                        that._trigger("focus");
                });
 
-               this._isOpen = true;
                this._trigger("open");
        },