Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-#10878] Fix bug of Getting Start Widget Accept Focus #11807

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export class GettingStartedContribution extends AbstractViewContribution<Getting
async onStart(app: FrontendApplication): Promise<void> {
if (!this.workspaceService.opened) {
this.stateService.reachedState('ready').then(
() => this.openView({ reveal: true })
() => this.openView({ reveal: true, activate: true })
);
}
}

override registerCommands(registry: CommandRegistry): void {
registry.registerCommand(GettingStartedCommand, {
execute: () => this.openView({ reveal: true }),
execute: () => this.openView({ reveal: true, activate: true }),
});
}

Expand Down
11 changes: 9 additions & 2 deletions packages/getting-started/src/browser/getting-started-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import * as React from '@theia/core/shared/react';
import URI from '@theia/core/lib/common/uri';
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
import { ReactWidget } from '@theia/core/lib/browser/widgets/react-widget';
import { CommandRegistry, isOSX, environment, Path } from '@theia/core/lib/common';
import { WorkspaceCommands, WorkspaceService } from '@theia/workspace/lib/browser';
import { KeymapsCommands } from '@theia/keymaps/lib/browser';
import { CommonCommands, LabelProvider, Key, KeyCode, codicon } from '@theia/core/lib/browser';
import { Message, ReactWidget, CommonCommands, LabelProvider, Key, KeyCode, codicon } from '@theia/core/lib/browser';
import { ApplicationInfo, ApplicationServer } from '@theia/core/lib/common/application-protocol';
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
Expand Down Expand Up @@ -111,6 +110,14 @@ export class GettingStartedWidget extends ReactWidget {
this.update();
}

protected override onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
const elArr = this.node.getElementsByTagName('a');
if (elArr && elArr.length > 0) {
(elArr[0] as HTMLElement).focus();
}
}

/**
* Render the content of the widget.
*/
Expand Down