diff options
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r-- | ui/jquery.ui.dialog.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index ef5787ef6..ec4032ff3 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -679,7 +679,10 @@ $.widget( "ui.dialog", { if ( $.ui.dialog.overlayInstances ) { this._on( this.document, { focusin: function( event ) { - if ( !$( event.target ).closest(".ui-dialog").length ) { + if ( !$( event.target ).closest(".ui-dialog").length && + // TODO: Remove hack when datepicker implements + // the .ui-front logic (#8989) + !$( event.target ).closest(".ui-datepicker").length ) { event.preventDefault(); $(".ui-dialog:visible:last .ui-dialog-content") .data("ui-dialog")._focusTabbable(); @@ -692,7 +695,7 @@ $.widget( "ui.dialog", { this.overlay = $("<div>") .addClass("ui-widget-overlay ui-front") - .appendTo( this.document[0].body ); + .appendTo( this._appendTo() ); this._on( this.overlay, { mousedown: "_keepFocus" }); @@ -704,11 +707,15 @@ $.widget( "ui.dialog", { return; } - $.ui.dialog.overlayInstances--; - if ( !$.ui.dialog.overlayInstances ) { - this._off( this.document, "focusin" ); + if ( this.overlay ) { + $.ui.dialog.overlayInstances--; + + if ( !$.ui.dialog.overlayInstances ) { + this._off( this.document, "focusin" ); + } + this.overlay.remove(); + this.overlay = null; } - this.overlay.remove(); } }); |