Skip to content

Commit

Permalink
Reposition output port edit UI after zooming
Browse files Browse the repository at this point in the history
  • Loading branch information
hlxid committed Mar 24, 2024
1 parent 42b5e6d commit 7ec7881
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/features/dfdElements/outputPortEditUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CommandReturn,
CommitModelAction,
MouseListener,
MouseTool,
SModelElementImpl,
SModelRootImpl,
SetUIExtensionVisibilityAction,
Expand Down Expand Up @@ -354,6 +355,7 @@ export class OutputPortEditUI extends AbstractUIExtension {
@inject(TYPES.IActionDispatcher) private actionDispatcher: ActionDispatcher,
@inject(TYPES.ViewerOptions) private viewerOptions: ViewerOptions,
@inject(TYPES.DOMHelper) private domHelper: DOMHelper,
@inject(MouseTool) private mouseTool: MouseTool,
@inject(PortBehaviorValidator) private validator: PortBehaviorValidator,

// Load label type registry watcher that handles changes to the behavior of
Expand All @@ -377,7 +379,7 @@ export class OutputPortEditUI extends AbstractUIExtension {

containerClass(): string {
// The container element gets this class name by the sprotty base class.
return "output-port-edit-ui";
return this.id();
}

protected initializeContents(containerElement: HTMLElement): void {
Expand Down Expand Up @@ -501,6 +503,20 @@ export class OutputPortEditUI extends AbstractUIExtension {
readOnly: this.editorModeController?.isReadOnly() ?? false,
});
});

const portEditUi = this;
class ZoomMouseListener extends MouseListener {
wheel(_target: SModelElementImpl, _event: WheelEvent): (Action | Promise<Action>)[] {
// Re-set position of the UI after next event loop tick.
// In the current event loop tick the scoll is still processed and the
// position of the port may change after the scroll processing, so we need to wait for that.
setTimeout(() => {
portEditUi.setPosition(containerElement);
});
return [];
}
}
this.mouseTool.register(new ZoomMouseListener());
}

protected onBeforeShow(
Expand Down

0 comments on commit 7ec7881

Please sign in to comment.