Opened 11 years ago

Closed 8 years ago

Last modified 7 years ago

#3539 closed bug (duplicate)

Stacked dialogs can be closed even when not in front

Reported by: BrianHV Owned by: Scott González
Priority: minor Milestone: 1.6
Component: ui.dialog Version: 1.6rc2
Keywords: Cc:
Blocked by: Blocking:

Description

The escape key can be used to close a modal dialog even when it's not in the front of the stacking order. Tested in IE7 with trunk.

<html>
    <body>
        <script type="text/javascript" language="javascript" src="jquery-1.2.6.js"></script>
        <script type="text/javascript" language="javascript" src="ui/ui.core.js"></script>
        <script type="text/javascript" language="javascript" src="ui/ui.dialog.js"></script>
        <div id="firstDialog"><h1>First Dialog</h1><a href="#" onclick="$('#secondDialog').dialog('open')">Now click this link</a></div>
        <div id="secondDialog"><h1>Second Dialog</h1><p>Now click the text "First Dialog" and then press escape.  The first dialog will close, leaving the second dialog stranded.</div>
        <p><a href="#" onclick="$('#firstDialog').dialog('open');">Click this link</a></p>
        <script type="text/javascript" language="javascript">
            $(document).ready(function(){
                $('#firstDialog').dialog({modal: true, width: 400, height: 400, overlay: { opacity: 0.5, background: 'black' }, autoOpen: false}).css('background', 'white');
                $('#secondDialog').dialog({modal: true, width: 200, height: 200, overlay: { opacity: 0.5, background: 'black' }, autoOpen: false}).css('background', 'white');
            });
        </script>
    </body>
</html>

Change History (8)

comment:1 Changed 11 years ago by Scott González

Milestone: TBD1.next

comment:2 Changed 11 years ago by Jörn Zaefferer

The dialog itself binds keydown event to itself for closing the dialog on ESC; in addition, the dialog overlay binds a keydown event to document, without filtering to close only the active dialog.

Instead of creating an overlay for each modal dialog, there should be just one overlay below the active dialog and above all others. Pressing ESC would then close the top dialog and move the overlay below the next dialog, or hide it if there is none.

comment:3 Changed 9 years ago by j4r3d

Status: newopen

Created a test case here: http://jsbin.com/ejomo4/2/edit

comment:5 Changed 8 years ago by Scott González

#7445 is a duplicate of this ticket.

comment:6 Changed 8 years ago by Scott González

Resolution: duplicate
Status: openclosed

comment:7 Changed 8 years ago by Scott González

Duplicate of #6966.

comment:8 Changed 7 years ago by Scott González

Milestone: 1.next1.6
Note: See TracTickets for help on using tickets.