Skip to content

Commit 80b873a

Browse files
authored
Prevent welcome page from stealing focus (microsoft#182796)
* Prevent welcome page from stealing focus * Fix comment
1 parent 4c6e0b5 commit 80b873a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,18 @@ export class GettingStartedPage extends EditorPane {
15541554
}
15551555

15561556
override focus() {
1557-
this.container.focus();
1557+
const active = document.activeElement;
1558+
1559+
let parent = this.container.parentElement;
1560+
while (parent && parent !== active) {
1561+
parent = parent.parentElement;
1562+
}
1563+
1564+
if (parent) {
1565+
// Only set focus if there is no other focued element outside this chain.
1566+
// This prevents us from stealing back focus from other focused elements such as quick pick due to delayed load.
1567+
this.container.focus();
1568+
}
15581569
}
15591570
}
15601571

0 commit comments

Comments
 (0)