TreeView reveal fails to scroll to item when focusing and a different selection exists (#156572)

Fixes #152803
This commit is contained in:
Alex Ross
2022-07-28 15:26:16 +02:00
committed by GitHub
parent e65cf31952
commit 1fdade8d07
@@ -496,12 +496,12 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
protected abstract activate(): void;
focus(reveal: boolean = true): void {
focus(reveal: boolean = true, revealItem?: ITreeItem): void {
if (this.tree && this.root.children && this.root.children.length > 0) {
// Make sure the current selected element is revealed
const selectedElement = this.tree.getSelection()[0];
if (selectedElement && reveal) {
this.tree.reveal(selectedElement, 0.5);
const element = revealItem ?? this.tree.getSelection()[0];
if (element && reveal) {
this.tree.reveal(element, 0.5);
}
// Pass Focus to Viewer
@@ -784,7 +784,7 @@ abstract class AbstractTreeView extends Disposable implements ITreeView {
setFocus(item: ITreeItem): void {
if (this.tree) {
this.focus();
this.focus(true, item);
this.tree.setFocus([item]);
}
}