Skip to content

Commit

Permalink
Dialog: Track the instance as soon as the dialog is opened
Browse files Browse the repository at this point in the history
Fixes #10152
  • Loading branch information
scottgonzalez committed Jul 23, 2014
1 parent 1071346 commit 69f25db
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ui/dialog.js
Expand Up @@ -273,6 +273,11 @@ return $.widget( "ui.dialog", {
that._trigger( "focus" );
});

// Track the dialog immediately upon openening in case a focus event
// somehow occurs outside of the dialog before an element inside the
// dialog is focused (#10152)
this._makeFocusTarget();

this._trigger( "open" );
},

Expand Down Expand Up @@ -584,14 +589,18 @@ return $.widget( "ui.dialog", {

_trackFocus: function() {
this._on( this.widget(), {
"focusin": function( event ) {
this._untrackInstance();
this._trackingInstances().unshift( this );
focusin: function( event ) {
this._makeFocusTarget();
this._focusedElement = $( event.target );
}
});
},

_makeFocusTarget: function() {
this._untrackInstance();
this._trackingInstances().unshift( this );
},

_untrackInstance: function() {
var instances = this._trackingInstances(),
exists = $.inArray( this, instances );
Expand Down

0 comments on commit 69f25db

Please sign in to comment.