Pause translation when appending the outline/attachment/layer trees to the sidebar

Also, pause translation when collapsing/expanding subtrees.
This commit is contained in:
Jonas Jenwald 2023-10-25 17:10:58 +02:00
parent 0fc899338c
commit 6b265b3a15
6 changed files with 41 additions and 2 deletions

View file

@ -25,6 +25,7 @@ class BaseTreeViewer {
}
this.container = options.container;
this.eventBus = options.eventBus;
this._l10n = options.l10n;
this.reset();
}
@ -99,10 +100,14 @@ class BaseTreeViewer {
* @private
*/
_toggleTreeItem(root, show = false) {
// Pause translation when collapsing/expanding the subtree.
this._l10n.pause();
this._lastToggleIsShow = show;
for (const toggler of root.querySelectorAll(".treeItemToggler")) {
toggler.classList.toggle("treeItemsHidden", !show);
}
this._l10n.resume();
}
/**
@ -122,7 +127,10 @@ class BaseTreeViewer {
this._lastToggleIsShow = !fragment.querySelector(".treeItemsHidden");
}
// Pause translation when inserting the tree into the DOM.
this._l10n.pause();
this.container.append(fragment);
this._l10n.resume();
this._dispatchEvent(count);
}