Skip to content

[AF-402] Fix model reinitialization issues with viewport and internal…#523

Merged
piotrblaszczyk merged 2 commits intomainfrom
af-402-fix-reinitialization
Jan 15, 2026
Merged

[AF-402] Fix model reinitialization issues with viewport and internal…#523
piotrblaszczyk merged 2 commits intomainfrom
af-402-fix-reinitialization

Conversation

@piotrblaszczyk
Copy link
Collaborator

Problem

Two issues occurred when reinitializing the same model:

  1. Viewport issues: After model reinitialization, zoomToFit didn't work and linking operations moved the whole viewport. Root cause: viewport.width and viewport.height were undefined because ResizeObserver doesn't fire when element size hasn't changed.

  2. Angular tracking issues: When the same model with identical node IDs was reinitialized, Angular's @for loop with trackBy using id couldn't distinguish between old and new nodes. The _internalId (used for forcing view recreation) was only assigned by middleware when nodes were added via transactions, not during initial model creation.

Solution

  1. Viewport fix: Added getViewportSize() callback to FlowCore and call initializeViewportSize() before render() to ensure viewport dimensions are set from element's getBoundingClientRect() on every initialization.

  2. Internal ID fix: _internalId is now assigned during initializeModel() as well, not only when adding nodes via middleware.

@piotrblaszczyk piotrblaszczyk merged commit 3cb8622 into main Jan 15, 2026
1 check passed
@piotrblaszczyk piotrblaszczyk deleted the af-402-fix-reinitialization branch January 15, 2026 13:25
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.

2 participants