*/
_callbackFocus: null,
+ /**
+ * @var {string}
+ */
+ _callbackCloseUuid: '',
+
/**
* @var boolean
*/
this._triggerElement = triggerElement;
this._options = options;
this._callbackFocus = null;
+ this._callbackCloseUuid = '';
this._proxy = new WCF.Action.Proxy({
showLoadingOverlay: false,
this._callbackFocus = this._maintainFocus.bind(this);
}
document.body.addEventListener('focus', this._callbackFocus, { capture: true });
+
+ this._callbackCloseUuid = WCF.System.Event.addListener('WCF.Dropdown.Interactive.Instance', 'close', (function (data) {
+ if (data.instance === this._dropdown) {
+ WCF.System.Event.removeListener('WCF.Dropdown.Interactive.Instance', 'close', this._callbackCloseUuid);
+ document.body.removeEventListener('focus', this._callbackFocus, { capture: true });
+ }
+ }).bind(this));
}
else {
elAttr(this._button, 'aria-expanded', false);
- document.body.removeEventListener('focus', this._callbackFocus);
+
+ WCF.System.Event.removeListener('WCF.Dropdown.Interactive.Instance', 'close', this._callbackCloseUuid);
+ document.body.removeEventListener('focus', this._callbackFocus, { capture: true });
}
return false;
}
if (elAttr(data.dialog, 'aria-hidden') === 'true') {
+ // close existing dropdowns
+ UiSimpleDropdown.closeAll();
+ window.WCF.Dropdown.Interactive.Handler.closeAll();
+
if (_callbackFocus === null) {
_callbackFocus = this._maintainFocus.bind(this);
document.body.addEventListener('focus', _callbackFocus, { capture: true });
id: id
});
}
-
- // close existing dropdowns
- UiSimpleDropdown.closeAll();
- window.WCF.Dropdown.Interactive.Handler.closeAll();
}
this.rebuild(id);