ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
61 stars 21 forks source link

fix merge issue with nested layouts #340

Closed loreanvictor closed 5 months ago

loreanvictor commented 5 months ago

Checklist

Motivation and Context

There was an issue with merging two states wherein layout information for nested elements wouldn't be recalculated properly.

Description

While merging two states, elements that used to have a parent in the old state but are without a parent in the new state wouldn't be calculated properly. This is used by the client for quickly accessing the root elements for rendering, and while it triggers on its own as a result of re-renders and layout updates, it sometimes caused elements to vanish momentarily after state merges (e.g. during realtime collaboration).

Steps for Testing

  1. Clone Apollon standalone and link local Apollon.
  2. Create a diagram and open it in collaboration mode in another browser window.
  3. Create a class element and a package element.
  4. Drag the class element inside the package, then drag it back outside.
  5. Without this fix, it is possible that the class will vanish. With this fix, this won't happen.

Test Coverage

File Branch Line
components/store/merge.ts 100% 100%

Screenshots

Without this fix:

ScreenRecording2024-01-22at07 53 16-ezgif com-video-to-gif-converter

With this fix:

ScreenRecording2024-01-22at07 55 04-ezgif com-video-to-gif-converter