Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/display/elements/Relations.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Graphics } from 'pixi.js';
import { calcOrientedBounds } from '../../utils/bounds';
import { relationsSchema } from '../data-schema/element-schema';
import { Relationstyleable } from '../mixins/Relationstyleable';
import { Linksable } from '../mixins/linksable';
import { Relationstyleable } from '../mixins/Relationstyleable';
import { mixins } from '../mixins/utils';
import Element from './Element';

Expand All @@ -21,7 +21,10 @@ export class Relations extends ComposedRelations {
}

update(changes, options) {
super.update(changes, relationsSchema, options);
super.update(changes, relationsSchema, {
...options,
mergeStrategy: 'replace',
});
}
Comment on lines 23 to 28

Choose a reason for hiding this comment

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

critical

While this change to use mergeStrategy: 'replace' correctly fixes the issue of the links array growing on each update, it introduces two significant problems:

  1. Broken Style Updates: This change causes a side effect where partial style updates no longer work. The _applyRelationstyle handler also uses mergeStrategy. With 'replace', it will replace the entire style on the underlying graphics object, instead of merging. For instance, updating just the width of a link will cause its color to be reset. This is a critical bug.

  2. Failing Tests: This change alters the behavior of links updates from merging to replacement. However, the existing tests in src/tests/render/Relations.test.js and src/tests/undo-redo/Relations.test.js still expect the old merging behavior (e.g., expect(updatedLinks.length).toBe(2)). These tests will now fail and need to be updated to reflect the new intended behavior.

A more targeted fix is needed. One approach is to refactor _applyRelationstyle to not depend on mergeStrategy. Alternatively, you could explore ways to apply the replace strategy only to the links array without affecting other properties during the update process.

Please address the style update bug and update the relevant tests.


initPath() {
Expand Down