Skip to content

Commit 69f25db

Browse files
committed
Dialog: Track the instance as soon as the dialog is opened
Fixes #10152
1 parent 1071346 commit 69f25db

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ui/dialog.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ return $.widget( "ui.dialog", {
273273
that._trigger( "focus" );
274274
});
275275

276+
// Track the dialog immediately upon openening in case a focus event
277+
// somehow occurs outside of the dialog before an element inside the
278+
// dialog is focused (#10152)
279+
this._makeFocusTarget();
280+
276281
this._trigger( "open" );
277282
},
278283

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

585590
_trackFocus: function() {
586591
this._on( this.widget(), {
587-
"focusin": function( event ) {
588-
this._untrackInstance();
589-
this._trackingInstances().unshift( this );
592+
focusin: function( event ) {
593+
this._makeFocusTarget();
590594
this._focusedElement = $( event.target );
591595
}
592596
});
593597
},
594598

599+
_makeFocusTarget: function() {
600+
this._untrackInstance();
601+
this._trackingInstances().unshift( this );
602+
},
603+
595604
_untrackInstance: function() {
596605
var instances = this._trackingInstances(),
597606
exists = $.inArray( this, instances );

0 commit comments

Comments
 (0)