Better support single/multiple UI updates

This commit is contained in:
nathan 2024-03-08 16:32:31 -07:00
parent eedd4a52dd
commit 7c9b3dd9e8
2 changed files with 24 additions and 1 deletions

View File

@ -493,6 +493,22 @@ export class Et2VfsSelectDialog
this.searchResultSelected();
}
/**
* Toggles a search result's selected state
*/
protected toggleResultSelection(result : HTMLElement & SearchResultElement, force? : boolean)
{
if(!this.multiple)
{
this._resultNodes.forEach(n =>
{
n.selected = false;
n.requestUpdate("selected");
});
}
super.toggleResultSelection(result, force);
}
/**
* This method must be called whenever the selection changes. It will update the selected file cache, the current
* value, and the display value

View File

@ -174,6 +174,8 @@ type Constructor<T = {}> = new (...args : any[]) => T;
* @param {T} superClass
* @returns {Constructor<SearchMixinInterface<DataType, Results>> & T}
* @constructor
*
* @event et2-select - Emitted when the selection changes
*/
export const SearchMixin = <T extends Constructor<Et2InputWidgetInterface &
{ egw() : IegwAppLocal, noLang : boolean } & LitElement>,
@ -464,7 +466,7 @@ export const SearchMixin = <T extends Constructor<Et2InputWidgetInterface &
/**
* Toggles a search result's selected state
*/
private toggleResultSelection(result : HTMLElement & SearchResultElement, force? : boolean)
protected toggleResultSelection(result : HTMLElement & SearchResultElement, force? : boolean)
{
if(force === true || force === false)
{
@ -503,6 +505,11 @@ export const SearchMixin = <T extends Constructor<Et2InputWidgetInterface &
this.value = [this.selectedResults[0]?.value] ?? [];
}
*/
this.updateComplete.then(() =>
{
this.dispatchEvent(new Event("et2-select"));
})
}