You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Overlay background links are accesible Created Mar 30, 2010

This thread is solved

Views: 1666     Replies: 2     Last reply Apr 7, 2010  
You must login first before you can use this feature

antimajain

Posts: 2

Registered:
Mar 26, 2010

Overlay background links are accesible

Posted: Mar 30, 2010

Just going through the overlay Demos, i noticed that if i open any overlay, and start pressing tab, i could see the keyboard Tab key is able to access the links behind the Tab, ideally the links behind the overlay should be disabled.and if i click i could move onto that particular page. Is there any way, to disable access behind the overlay through the keyboard.

HitmanInWi

Posts: 2

Registered:
Apr 7, 2010

Very surprising

Posted: Apr 7, 2010

Reply to: Overlay background links are accesible, from antimajain
Yes indeed the modal overlay is not actually modal. Even though the user cannot use the mouse to click background items such as buttons and links, they can certainly tab to those controls in the background and invoke them, which is definitely unexpected.

This really shouldn't be very difficult to patch - the dialog for jquery ui already does this.

See the code commented "// prevent tabbing out of modal dialogs"

http://code.google.com/p/jquery-ui/source/browse/trunk/ui/jquery.ui.dialog.js

HitmanInWi

Posts: 2

Registered:
Apr 7, 2010

Temporary Solution

Posted: Apr 7, 2010

Reply to: Very surprising, from HitmanInWi
Here's a temporary fix that I wrote:


/**
 * Author: Brett Birschbach - HS2 Solutions, Inc.
 */
(function($) {
    $.fn.overlay__orig = $.fn.overlay;
    $.fn.overlay = function(args) { 
        var overlay = this.overlay__orig(args);
        if (overlay.load__orig == undefined) {overlay.load__orig = overlay.load};
        if (overlay.close__orig == undefined) {overlay.close__orig = overlay.close};
        overlay.load = function() {
            var loaded = this.load__orig();
            if (!this.getConf().closeOnClick) {
                /*
                 * NOTE THAT THE FOLLOWING CODE WAS PULLED FROM jquery.ui.dialog.js 
                 *  
                 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
                 * Dual licensed under the MIT (MIT-LICENSE.txt)
                 * and GPL (GPL-LICENSE.txt) licenses.
                 *
                 * http://docs.jquery.com/UI/Dialog
                 */
                this.getOverlay().bind('keypress.overlay', function(event) {
                    if (event.keyCode !== $.ui.keyCode.TAB) {
                        return;
                    }
    
                    var tabbables = $(':tabbable', this);
                    var first = tabbables.filter(':first');
                    var last  = tabbables.filter(':last');
    
                    if (event.target === last[0] && !event.shiftKey) {
                        first.focus(1);
                        return false;
                    } else if (event.target === first[0] && event.shiftKey) {
                        last.focus(1);
                        return false;
                    }
                });
                /* END CODE from http://docs.jquery.com/UI/Dialog */
            }
            return loaded;
        };
        overlay.close = function() {
            this.getOverlay().unbind('keypress.overlay');
            return this.close__orig();
        };
        return overlay;
    };
})(jQuery);

I believe you will need the jQuery UI plugin for the ":tabbable" selector to work.