Permalink
Browse files

[popup] Restrict focus to elements inside the popup -- Fixes #5130

Caveat: This kind of focus restriction can still be circumvented using FF's type-to-search feature
  • Loading branch information...
gabrielschulhof committed Oct 9, 2012
1 parent 823e54a commit 39aea2b93315ff668b0aea428b08b4d3d31b66cc
Showing with 15 additions and 0 deletions.
  1. +15 −0 js/widgets/popup.js
View
@@ -143,6 +143,18 @@ define( [ "jquery",
}
},
// When the popup is open, attempting to focus on an element that is not a child of the popup will redirect focus to the popup
_handleDocumentFocusIn: function( e ) {
if ( this._isOpen &&
e.target !== this._ui.container[ 0 ] &&
0 === $( e.target ).parents().filter( this._ui.container[ 0 ] ).length ) {
this._ui.container.focus();
e.preventDefault();
e.stopImmediatePropagation();
return false;
}
},
_create: function() {
var ui = {
screen: $( "<div class='ui-screen-hidden ui-popup-screen'></div>" ),
@@ -208,6 +220,9 @@ define( [ "jquery",
resize: $.proxy( this, "_handleWindowResize" ),
keyup: $.proxy( this, "_handleWindowKeyUp" )
});
this._on( $( document ), {
focusin: $.proxy( this, "_handleDocumentFocusIn" )
});
},
_applyTheme: function( dst, theme, prefix ) {

0 comments on commit 39aea2b

Please sign in to comment.