Ticket #9000 (closed bug: fixed)

Opened 19 months ago

Last modified 15 months ago

Dialog leaves broken event handler after close/destroy in certain cases

Reported by: olejorgenb Owned by:
Priority: blocker Milestone: 1.10.1
Component: ui.dialog Version: 1.10.0
Keywords: regression Cc:
Blocking: Blocked by:

Description

(See attached testcase)

Create and open a modal dialog. Close it. Destroy it. Focus an element in a separate javascript block/"thread" later.

Result:

Uncaught TypeError: Cannot call method '_focusTabbable' of undefined jquery-ui-1.10.0.custom.js:5730
$.widget._createOverlay._delay._on.focusin jquery-ui-1.10.0.custom.js:5730
handlerProxy jquery-ui-1.10.0.custom.js:706
jQuery.event.dispatch jquery-1.8.3.js:3058
jQuery.event.add.elemData.handle.eventHandle jquery-1.8.3.js:2676
jQuery.event.trigger jquery-1.8.3.js:2941
jQuery.fn.extend.trigger jquery-1.8.3.js:3599
jQuery.extend.each jquery-1.8.3.js:611
jQuery.fn.jQuery.each jquery-1.8.3.js:241
jQuery.fn.extend.trigger jquery-1.8.3.js:3598
jQuery.each.jQuery.fn.(anonymous function) jquery-1.8.3.js:3652
$.fn.extend.focus jquery-ui-1.10.0.custom.js:62
(anonymous function) test.html:11

This happens (ASFAICS) because _destroyOverlay is called both on close and destroy, decreasing $.ui.dialog.overlayInstances twice, causing the check marked below to not work as intended.

	_createOverlay: function() {
		if ( !this.options.modal ) {
			return;
		}

		if ( !$.ui.dialog.overlayInstances ) {
			// Prevent use of anchors and inputs.
			// We use a delay in case the overlay is created from an
			// event that we're going to be cancelling. (#2804)
			this._delay(function() {
				// Handle .dialog().dialog("close") (#4065)
------>				if ( $.ui.dialog.overlayInstances ) {
					this._on( this.document, {
						focusin: function( event ) {
							if ( !$( event.target ).closest(".ui-dialog").length ) {
								event.preventDefault();
								$(".ui-dialog:visible:last .ui-dialog-content")
									.data("ui-dialog")._focusTabbable();
							}
						}
					});
				}
			});
		}

Change History

comment:1 Changed 19 months ago by olejorgenb

Can't upload attachments? Here's an jsfiddle  http://jsfiddle.net/FUMfS/

comment:2 Changed 19 months ago by scott.gonzalez

  • Keywords regression added
  • Priority changed from minor to major
  • Status changed from new to open
  • Milestone changed from none to 1.10.1

comment:3 Changed 19 months ago by scott.gonzalez

  • Priority changed from major to blocker

Related to #9004.

comment:5 Changed 19 months ago by petersendidit

  • Status changed from open to closed
  • Resolution set to fixed

Dialog: Don't handle overlays on destory if there are not any. Fixed: #9004 - failed in _destroyOverlay when I destroy a modal dialog thau was never opened. Fixed: #9000 Dialog leaves broken event handler after close/destroy in certain cases

Changeset: 649f105229b2a24adc21cba2d56cb05a59711ccb

comment:6 Changed 18 months ago by rksii

This says closed but I built from the latest code and the bug is still there.

Last edited 18 months ago by rksii (previous) (diff)

comment:7 Changed 18 months ago by scott.gonzalez

@rksii Do you have a reduced test case proving that?

comment:8 Changed 15 months ago by TUX

Last edited 15 months ago by scott.gonzalez (previous) (diff)

comment:9 Changed 15 months ago by TUX

Last edited 15 months ago by scott.gonzalez (previous) (diff)

comment:10 Changed 15 months ago by scott.gonzalez

@TUX Please stop posting blocks of code into the ticket. This ticket has been closed for a while. If there's a new bug, please file a new ticket.

comment:11 Changed 15 months ago by TUX

Comenten esta linea de codigo del Jquery y con eso se soluciona:

$(".ui-dialog:visible:last .ui-dialog-content")

.data("ui-dialog")._focusTabbable();

Saludos desde Merida, Yucatan...

Note: See TracTickets for help on using tickets.