Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#4652 closed bug (fixed)

Dialog: Event loss in subsequent dialog calls (FF3)

Reported by: rlandrum Owned by:
Priority: minor Milestone: 1.8.7
Component: ui.dialog Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

I recently had (I fixed it) an issue with Modal dialogs.

I have defined in my application two modals. Each has a text editable form field. When I open one of the modals, and close it (a close event handler calls .dialog('destroy')), any additional modals I open have no events.

I tracked this (over several hours, sadly) to the overlay. All of my events were being blocked by the overlay, even though my modal was on top. This is because the zIndex for the overlay was 'NaN'. 'NaN' is greater than the zIndex of the modal and the end result is that the keypress and other event handlers from the overlay block the keypress handlers from the modal.

The overlay, as it turns out, is getting NaN from the dialog. Once a dialog is closed, it attempts to find the largest zIndex of all the .ui-dialog classed DOM objects. Unfortunately, this is done with

$(this).css('z-index')

Which in FF3 returns 'auto' for non-zIndexed objects with the .ui-dialog class. (Don't ask why I have ui-dialog classed objects.)

The fix is pretty simple,

Replace: maxZ = Math.max(maxZ, $(this).css('z-index'));

With: var i = $(this).css('z-index'); if(!i.isNaN()) {

maxZ = Math.max(maxZ,i);

}

Change History (6)

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

Milestone: TBD1.8

comment:2 Changed 13 years ago by dalexandre

Thanks A LOT dude :-)

In fact the bug can be fixed by adding

.ui-dialog
{
  z-index: 0;
}

In your CSS (so no need to patch the code). That way all the .ui-dialog HAVE a default z-index not set to "auto".

I was having HUGE issues in a big webapp with a lot of .ui-dialog class set.

comment:3 Changed 13 years ago by jamiejag

I've tried to make a correction to the source. Haven't done this before and there are a lot of hoops to jump through. Hopefully it will take.

https://github.com/jquery/jquery-ui/pull/43

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

Summary: Event loss in subsequent dialog calls (FF3)Dialog: Event loss in subsequent dialog calls (FF3)

comment:5 Changed 13 years ago by jamiejag

Resolution: fixed
Status: newclosed

Dialog: Ensure dialogs have a z-index when calculating the max z-index. Fixex #5955 - Dialog: Closing UI dialog when z-index is not defined in any .ui-dialog class, causes NaN to be used as Z-index, throwing an error. Fixes #4652 - Dialog: Event loss in subsequent dialog calls (FF3).

Changeset: 8bb412dd4a09d66d0f4a5456410a647e3db38bcc

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

Milestone: 1.91.8.7
Note: See TracTickets for help on using tickets.