Skip to main content

Search and Top Navigation

#9000 closed bug (fixed)

Opened January 22, 2013 02:47PM UTC

Closed January 25, 2013 03:36AM UTC

Last modified June 04, 2013 03:45PM UTC

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:
Blocked by: Blocking:
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();
							}
						}
					});
				}
			});
		}
Attachments (0)
Change History (11)

Changed January 22, 2013 02:54PM UTC by olejorgenb comment:1

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

Changed January 22, 2013 03:07PM UTC by scottgonzalez comment:2

keywords: → regression
milestone: none1.10.1
priority: minormajor
status: newopen

Changed January 23, 2013 01:41PM UTC by scottgonzalez comment:3

priority: majorblocker

Related to #9004.

Changed January 24, 2013 01:37AM UTC by petersendidit comment:4

Changed January 25, 2013 03:36AM UTC by petersendidit comment:5

resolution: → fixed
status: openclosed

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

Changed February 21, 2013 07:52PM UTC by rksii comment:6

_comment0: This says closed but I am using 1.10.1 and the bug is still there. 1361478872642857

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

Changed February 21, 2013 07:55PM UTC by scottgonzalez comment:7

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

Changed June 04, 2013 03:26PM UTC by scottgonzalez comment:8

_comment0: _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(); \ ------Comenten esta parte del codigo------------------> /*$(".ui-dialog:visible:last .ui-dialog-content") \ ------Con eso se soluciona------------------> .data("ui-dialog")._focusTabbable();*/ \ } \ } \ }); \ } \ }); \ }1370359913694203

Changed June 04, 2013 03:29PM UTC by scottgonzalez comment:9

_comment0: _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();*/ \ } \ } \ }); \ } \ }); \ } \ \ \ Comenten esta parte del codigo y con esto se soluciona: \ \ $(".ui-dialog:visible:last .ui-dialog-content") \ .data("ui-dialog")._focusTabbable(); \ \ \ Saludos desde Merida, Yucatan.1370359904475753

Changed June 04, 2013 03:30PM UTC by scottgonzalez comment:10

@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.

Changed June 04, 2013 03:45PM UTC by TUX comment:11

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...