Skip to content

Commit

Permalink
[GH-#10878] Fix bug of Getting Start Widget Accept Focus
Browse files Browse the repository at this point in the history
Signed-off-by: White Hsu <[email protected]>

==
To modify getting-started-contribution.ts to pass activate to the openView methods.
To focus on the first available link in getting-started-widget.tsx.
[Question] But the warning below still exists. May I ask your kind suggestion? Thank you very much.
--
WARN Widget was activated, but did not accept focus after 2000ms: getting.started.widget
--
  • Loading branch information
WhiteHsu committed Nov 17, 2022
1 parent 7f51450 commit 52f18c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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
10 changes: 9 additions & 1 deletion packages/getting-started/src/browser/getting-started-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
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 { Message, ReactWidget } from '@theia/core/lib/browser';
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';
Expand Down Expand Up @@ -111,6 +111,14 @@ export class GettingStartedWidget extends ReactWidget {
this.update();
}

protected override onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
const elArr = document.getElementsByClassName('gs-action-container');
if (elArr && elArr.length > 0) {
(elArr[0] as HTMLElement).focus();
}
}

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

0 comments on commit 52f18c4

Please sign in to comment.