fix: fire selection `CHANGE` event to correct listener (#118)

The `CHANGE` event is now fired to `GraphSelectionModel` instead of `Graph`.
This is the behavior of mxGraph that was mistakenly modified during the migration of the code.
development
Анатолий Майоров 2022-12-08 10:49:02 +03:00 committed by GitHub
parent a3b5a60c60
commit 3954001a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -63,7 +63,7 @@ class SelectionCellsHandler extends EventSource implements GraphPlugin {
} }
}; };
this.graph.addListener(InternalEvent.CHANGE, this.refreshHandler); this.graph.getSelectionModel().addListener(InternalEvent.CHANGE, this.refreshHandler);
this.graph.getDataModel().addListener(InternalEvent.CHANGE, this.refreshHandler); this.graph.getDataModel().addListener(InternalEvent.CHANGE, this.refreshHandler);
this.graph.getView().addListener(InternalEvent.SCALE, this.refreshHandler); this.graph.getView().addListener(InternalEvent.SCALE, this.refreshHandler);
this.graph.getView().addListener(InternalEvent.TRANSLATE, this.refreshHandler); this.graph.getView().addListener(InternalEvent.TRANSLATE, this.refreshHandler);

View File

@ -49,11 +49,11 @@ class SelectionChange implements UndoableChange {
selectionModel.updatingSelectionResource; selectionModel.updatingSelectionResource;
for (const removed of this.removed) { for (const removed of this.removed) {
this.graph.getSelectionModel().cellRemoved(removed); selectionModel.cellRemoved(removed);
} }
for (const added of this.added) { for (const added of this.added) {
this.graph.getSelectionModel().cellAdded(added); selectionModel.cellAdded(added);
} }
[this.added, this.removed] = [this.removed, this.added]; [this.added, this.removed] = [this.removed, this.added];
@ -61,7 +61,7 @@ class SelectionChange implements UndoableChange {
window.status = window.status =
Translations.get(selectionModel.doneResource) || selectionModel.doneResource; Translations.get(selectionModel.doneResource) || selectionModel.doneResource;
this.graph.fireEvent( selectionModel.fireEvent(
new EventObject(InternalEvent.CHANGE, { added: this.added, removed: this.removed }) new EventObject(InternalEvent.CHANGE, { added: this.added, removed: this.removed })
); );
} }