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

GLSP-1354: Improve viewport restore on diagram open #218

Merged
merged 1 commit into from
Jul 1, 2024
Merged

Conversation

tortmayr
Copy link
Contributor

What it does

Move viewport restoration logic from the diagram manager to the onAfterAttach method of the diagram widget. This ensures that the viewport restoration allways works independently of how the diagram has been created (WidgetOpenHandler vs. direct creation). Fixes eclipse-glsp/glsp#1354

Also

  • Move RequestModelOptions generation into a submethod for easier extendibility
  • Register the mouse enter/mouse leave listeners via the addEventListener utility method which already has built-in dispose on detach behavior

How to test

Follow-ups

Changelog

  • This PR should be mentioned in the changelog
  • This PR introduces a breaking change (if yes, provide more details below for the changelog and the migration guide)

Move viewport restoration logic from the diagram manager to the `onAfterAttach` method of the diagram widget. This ensures that the viewport restoration allways works independently of how the diagram has been created (WidgetOpenHandler vs. direct creation).
Fixes eclipse-glsp/glsp#1354

Also
- Move `RequestModelOptions` generation into a submethod for easier extendibility
- Register the mouse enter/mouse leave listeners via the `addEventListener` utility method which already has built-in dispose on detach behavior
Copy link
Contributor

@martin-fleck-at martin-fleck-at left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me, thank you Tobias! And thank you for the additional documentation ;-)

@@ -139,8 +141,8 @@ export class GLSPDiagramWidget extends BaseWidget implements SaveableSource, Sta
this.addClipboardListener(this.node, 'paste', e => this.handlePaste(e));
this.addClipboardListener(this.node, 'cut', e => this.handleCut(e));
}
this.node.addEventListener('mouseenter', e => this.handleMouseEnter(e));
this.node.addEventListener('mouseleave', e => this.handleMouseLeave(e));
this.addEventListener(this.node, 'mouseenter', e => this.handleMouseEnter(e));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@tortmayr tortmayr merged commit 2befd10 into master Jul 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Viewport restore only works if the diagram widget is created via WidgetOpenHandler
2 participants