Preferences: Add a preference for if select multiple dropdowns stay open or closes immediately after selection

This commit is contained in:
nathan
2023-04-17 09:28:27 -06:00
parent b557eb7b83
commit 358cc70d66
4 changed files with 112 additions and 81 deletions

View File

@ -244,12 +244,22 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
*/
private _block_change_event = false;
/**
* Close the dropdown after user selects an option.
* Only applies when multiple="true". We initialize it in constructor to the common preference "select_multiple_close"
* @type {boolean}
* @private
*/
private _close_on_select : boolean;
constructor(...args : any[])
{
super();
// We want this on more often than off
this.hoist = true;
this._close_on_select = this.egw().preference("select_multiple_close") == "close";
this._triggerChange = this._triggerChange.bind(this);
this._doResize = this._doResize.bind(this);
this._handleMouseWheel = this._handleMouseWheel.bind(this);
@ -683,8 +693,8 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
}
/**
* Always close the dropdown if an option is clicked, even if multiple=true. This differs from SlSelect,
* which leaves the dropdown open for multiple=true
* Apply the user preference to close the dropdown if an option is clicked, even if multiple=true.
* The default (from SlSelect) leaves the dropdown open for multiple=true
*
* @param {MouseEvent} event
* @private
@ -696,14 +706,17 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
// Don't hide dropdown when clicking on select. That can close it after user opens it.
return;
}
this.dropdown.hide().then(() =>
if(this._close_on_select)
{
if(typeof this.handleMenuHide == "function")
this.dropdown.hide().then(() =>
{
// Make sure search gets hidden
this.handleMenuHide();
}
});
if(typeof this.handleMenuHide == "function")
{
// Make sure search gets hidden
this.handleMenuHide();
}
});
}
}
/**

View File

@ -83,6 +83,10 @@ export class Et2SelectEmail extends Et2Select
constructor(...args : any[])
{
super(...args);
// Always off for select email, per ticket #79694
this._close_on_select = true;
this.search = true;
this.searchUrl = "EGroupware\\Api\\Etemplate\\Widget\\Taglist::ajax_email";
this.allowFreeEntries = true;