Ticket #9000 (closed bug: fixed)
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:2 Changed 4 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 4 months ago by scott.gonzalez
- Priority changed from major to blocker
Related to #9004.
comment:5 Changed 4 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
Note: See
TracTickets for help on using
tickets.


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