Skip to content

Commit 0b7b0dd

Browse files
committed
Address review feedback
- Fix "goToPreviousNode" command definition - Ensure that diagram widget focus state changes are forwarded to the GLSP FocusTracker
1 parent d0f662c commit 0b7b0dd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

example/workflow/extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
},
151151
{
152152
"command": "workflow.goToPreviousNode",
153-
"group": "",
153+
"group": "navigation",
154154
"when": "activeCustomEditorId == 'workflow.glspDiagram' && workflow.editorSelectedElementsAmount == 1"
155155
},
156156
{

packages/vscode-integration-webview/src/glsp-diagram-widget.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
import {
1919
DiagramLoader,
2020
DiagramLoadingOptions,
21+
FocusStateChangedAction,
2122
IActionDispatcher,
2223
IDiagramOptions,
2324
ModelSource,
2425
TYPES,
2526
ViewerOptions
2627
} from '@eclipse-glsp/client';
2728
import { inject, injectable, postConstruct } from 'inversify';
28-
2929
export const GLSPDiagramWidgetFactory = Symbol('GLSPDiagramWidgetFactory');
3030
export type GLSPDiagramWidgetFactory = () => GLSPDiagramWidget;
3131

@@ -71,6 +71,8 @@ export abstract class GLSPDiagramWidget {
7171
this.containerDiv = containerDiv;
7272
containerDiv.addEventListener('mouseenter', e => this.handleMouseEnter(e));
7373
containerDiv.addEventListener('mouseleave', e => this.handleMouseLeave(e));
74+
window.addEventListener('focus', e => this.handleFocusChange(e, true));
75+
window.addEventListener('blur', e => this.handleFocusChange(e, false));
7476
}
7577
}
7678

@@ -84,6 +86,10 @@ export abstract class GLSPDiagramWidget {
8486
this.containerDiv?.classList.remove('mouse-enter');
8587
}
8688

89+
handleFocusChange(e: FocusEvent, hasFocus: boolean): void {
90+
this.actionDispatcher.dispatch(FocusStateChangedAction.create(hasFocus));
91+
}
92+
8793
protected createDiagramLoadingOptions(): DiagramLoadingOptions | undefined {
8894
return undefined;
8995
}

0 commit comments

Comments
 (0)