Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#5365 closed bug (duplicate)

ESC key problem

Reported by: fredericomf Owned by:
Priority: major Milestone: 1.9.0
Component: ui.dialog Version: 1.8rc3
Keywords: Cc:
Blocked by: Blocking:


When i created two modal dialogs using UI the second dialog don't listen the ESC key event.

This is the structure of modal dialogs:

<div id="modal01">
  Some Text
  <a id="showSecondDialog">NEW</a>
  <div id="modal02">
    Some Text

Both dialogs has option: autoOpen: false.

The trigger to show the second dialog is a button inside a first dialog.

Pressing ESC key the first dialog is closed and the second don't close.

Change History (4)

comment:1 Changed 13 years ago by watanabe


  1. Open a modal dialog having a button to open a child modal dialog.
  2. Open the child dialog.
  3. Click the overlay.
  4. Press ESC key.

jQuery UI 1.8.1 Uncompressed version

line 702 (overlay create)


line 72 (dialog _create)


line 683 (overlay create)

if (this.instances.length === 0) {

in line 702, "dialog" means "the first dialog".

comment:2 Changed 13 years ago by bostanio

The problem here is that we only bind the 'keydown.dialog-overlay' event once and for the first overlay created (so for the first modal dialog). The fix is to still only bind the event once but have the event search the instances for the 'top' overlay (by zIndex) and close it's dialog. This also necessitates the overlay having a back reference to it's dialog but that is easy to do.

Note that there is a second bug lurking here that hitting escape with the focus in the second dialog would close both dialogs. First you close the top dialog and then the ESCAPE keydown event propagates to the overlay and closes the next dialog. Simple fix is to stop the event propagating.

Both fixes and visual test case are in these commits (second is useful comments):


comment:3 Changed 12 years ago by Scott González

Resolution: duplicate
Status: newclosed

comment:4 Changed 12 years ago by Scott González

Duplicate of #6966.

Note: See TracTickets for help on using tickets.