Skip to content

Commit 5eb836d

Browse files
committed
refactor: Replace timeouts with robust DOM waits in TreeList logic (#8560)
1 parent e7cdfcf commit 5eb836d

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

apps/portal/view/news/tickets/MainContainerController.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,13 @@ class MainContainerController extends Controller {
123123
tree.expandParents(itemId);
124124

125125
if (!oldValue?.hashString?.startsWith('/news/tickets')) {
126-
await me.timeout(100);
127-
tree.scrollToItem(itemId)
126+
// Wait for the expansion VDOM update to be applied and the item to be visible in the DOM
127+
const id = tree.getItemId(itemId),
128+
rect = await tree.waitForDomRect({id, attempts: 20, delay: 20});
129+
130+
if (rect) {
131+
tree.scrollToItem(itemId)
132+
}
128133
}
129134
};
130135

apps/portal/view/shared/content/TreeList.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class TreeList extends BaseTreeList {
6464
*/
6565
async afterSetCurrentPageRecord(value, oldValue) {
6666
if (value) {
67-
await this.timeout(20);
6867
this.selectionModel.select(value)
6968
}
7069
}

0 commit comments

Comments
 (0)