Opened 20 months ago

Closed 19 months ago

Last modified 19 months ago

#13649 closed bug (fixed)

Modal dialog removes all document focusin handlers in _destroyOverlay

Reported by: RandScullard Owned by:
Priority: minor Milestone: 1.12.0
Component: ui.dialog Version: 1.11.4
Keywords: Cc:
Blocked by: Blocking:

Description

The dialog widget uses this._on to add a focusin event handler at the document level in the _createOverlay function:

this._on( this.document, {
	focusin: function( event ) {
		if ( isOpening ) {
			return;
		}

		if ( !this._allowInteraction( event ) ) {
			event.preventDefault();
			this._trackingInstances()[ 0 ]._focusTabbable();
		}
	}
});

However, it then uses unbind to remove the handler in the _destroyOverlay function:

this.document
	.unbind( "focusin" )
	.removeData( "ui-dialog-overlays" );

As a result, it removes all focusin handlers at the document level, rather than just its own. It seems that it should use this._off instead:

this._off( this.document, "focusin" );
this.document
	.removeData( "ui-dialog-overlays" );

Here is a reduced test case that demonstrates the problem: https://jsfiddle.net/eu4ua6kj/2/

Change History (2)

comment:1 Changed 19 months ago by Scott González

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

Dialog: Fix removal of event listener for modal dialogs

Fixes #13649

Changeset: 62446d957efb69cd53015919edf71501fcbd2599

comment:2 Changed 19 months ago by scottgonzalez

  • Milestone changed from none to 1.12.0
Note: See TracTickets for help on using tickets.