Skip to content

Commit b287a6a

Browse files
authored
Fix the focus issue when triggering 'Configure Java Runtime' (#1337)
- Makes sure the route change notification is sent after the react component is ready.
1 parent 9961fa6 commit b287a6a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/project-settings/assets/mainpage/features/ProjectSettingView.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ const ProjectSettingView = (): JSX.Element => {
4444
if (routes.length > 1) {
4545
switch (routes[0]) {
4646
case SectionId.Classpath:
47-
// TODO: sometimes when directly trigger 'Configure Java Runtime', the tab won't
48-
// focus to the JDK part, need to investigate
4947
dispatch(updateActiveTab(routes[1]));
5048
break;
5149
default:

src/project-settings/projectSettingsView.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ class ProjectSettingView {
2727
}
2828

2929
projectSettingsPanel.reveal();
30-
projectSettingsPanel.webview.postMessage({
31-
command: "main.onWillChangeRoute",
32-
route: sectionId
33-
});
30+
const oneTimeHook = projectSettingsPanel.webview.onDidReceiveMessage(() => {
31+
// send the route change msg once react component is ready.
32+
// and dispose it once it's done.
33+
projectSettingsPanel!.webview.postMessage({
34+
command: "main.onWillChangeRoute",
35+
route: sectionId
36+
});
37+
oneTimeHook.dispose();
38+
})
3439
}
3540

3641
public async initializeWebview(context: vscode.ExtensionContext): Promise<void> {

0 commit comments

Comments
 (0)