diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 23f91ef52f..a63f89e0a6 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -509,7 +509,10 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin { let item = this.getNode(_id); // if the item does not exist in the tree yet no need to refresh - if(item == null) return + if(item == null) + { + return Promise.resolve(); + } return this.handleLazyLoading(item).then((result) => { item.item = [...result.item] this.requestUpdate("_selectOptions") @@ -1039,6 +1042,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin > + ${repeat(this._selectOptions, (o) => o.value, this._optionTemplate)} `; diff --git a/mail/js/app.js b/mail/js/app.js index 1d74109cbb..270ad85c8d 100755 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -677,8 +677,19 @@ app.classes.mail = AppJS.extend( break; case 'add': const current_id = tree.getValue(); - // need to wait tree is refreshed: current and new id are there AND current folder is selected again - tree.refreshItem(0).then(() => { + + tree._selectOptions.push({ + id: "" + _id, + label: this.egw.lang("Loading..."), + selected: false, + loading: true, + lazy: true + }); + tree.requestUpdate("_selectOptions"); + tree.updateComplete.then(async () => + { + // need to wait tree is refreshed: current and new id are there AND current folder is selected again + await tree.refreshItem(_id); if (tree.getNode(_id) && tree.getNode(current_id)) { if (!tree.getSelectedNode()) @@ -689,16 +700,19 @@ app.classes.mail = AppJS.extend( { // open new account // need to wait new folders are loaded AND current folder is selected again - tree.openItem(_id, true).then(() => { - if (tree.getNode(_id + '::INBOX')) { - if (!tree.getSelectedNode()) { - tree.reSelectItem(current_id); - } else { - this.mail_changeFolder(_id + '::INBOX', tree, current_id); - tree.reSelectItem(_id + '::INBOX'); - } + await tree.openItem(_id, true); + if (tree.getNode(_id + '::INBOX')) + { + if (!tree.getSelectedNode()) + { + tree.reSelectItem(current_id); } - }); + else + { + this.mail_changeFolder(_id + '::INBOX', tree, current_id); + tree.reSelectItem(_id + '::INBOX'); + } + } } } });