Skip to content

Commit

Permalink
[theia] fix focus on activation
Browse files Browse the repository at this point in the history
Focus the node of a widget if the `svgElement` hasn't been created yet

Fixes #45
  • Loading branch information
JanKoehnlein committed Nov 5, 2019
1 parent a1549c6 commit 077bb0a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/theia/diagram-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,14 @@ export class DiagramWidget extends BaseWidget implements StatefulWidget, Navigat
protected onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
const svgElement = this.node.querySelector(`#${this.viewerOptions.baseDiv} svg`) as HTMLElement;
if (svgElement !== null)
if (svgElement !== null) {
svgElement.focus();
} else {
const tabindex = this.node.getAttribute('tabindex');
if (tabindex === null)
this.node.setAttribute('tabindex', -1);
this.node.focus();
}
}

/**
Expand Down

0 comments on commit 077bb0a

Please sign in to comment.