Skip to content

Commit 51eb28e

Browse files
committed
Dialog: Extract check for which elements can gain focus into its own method for overriding. Fixes #9087 - Dialog: Allow registering elements outside a dialog for use when a modal dialog is open.
1 parent 10ca483 commit 51eb28e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ui/jquery.ui.dialog.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -692,12 +692,23 @@ $.widget( "ui.dialog", {
692692
}
693693
},
694694

695+
_allowInteraction: function( event ) {
696+
if ( $( event.target ).closest(".ui-dialog").length ) {
697+
return true;
698+
}
699+
700+
// TODO: Remove hack when datepicker implements
701+
// the .ui-front logic (#8989)
702+
return !!$( event.target ).closest(".ui-datepicker").length;
703+
},
704+
695705
_createOverlay: function() {
696706
if ( !this.options.modal ) {
697707
return;
698708
}
699709

700-
var widgetFullName = this.widgetFullName;
710+
var that = this,
711+
widgetFullName = this.widgetFullName;
701712
if ( !$.ui.dialog.overlayInstances ) {
702713
// Prevent use of anchors and inputs.
703714
// We use a delay in case the overlay is created from an
@@ -706,10 +717,7 @@ $.widget( "ui.dialog", {
706717
// Handle .dialog().dialog("close") (#4065)
707718
if ( $.ui.dialog.overlayInstances ) {
708719
this.document.bind( "focusin.dialog", function( event ) {
709-
if ( !$( event.target ).closest(".ui-dialog").length &&
710-
// TODO: Remove hack when datepicker implements
711-
// the .ui-front logic (#8989)
712-
!$( event.target ).closest(".ui-datepicker").length ) {
720+
if ( !that._allowInteraction( event ) ) {
713721
event.preventDefault();
714722
$(".ui-dialog:visible:last .ui-dialog-content")
715723
.data( widgetFullName )._focusTabbable();

0 commit comments

Comments
 (0)