Skip to content

Commit

Permalink
Unregister events properly when layer changes and / or component is c…
Browse files Browse the repository at this point in the history
…losed
  • Loading branch information
sronveaux committed Jun 20, 2024
1 parent fe48724 commit 8995f6f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/components/attributeTable/AttributeTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export default {
// unregister event after table is closed
this.layer.getSource().un('change', this.prepareTableDataAndColumns);
}
if (this.syncTableMapSelection) {
this.deactivateSelectRowOnMapClick();
}
},
watch: {
layerId () {
Expand Down Expand Up @@ -172,6 +176,14 @@ export default {
});
},
/**
* Deactivate behaviour that a selected feature on the
* map will be selected in the AttributeTable as well.
*/
deactivateSelectRowOnMapClick () {
WguEventBus.$off('map-selectionchange');
},
/**
* Highlight row matching the feature ID
* and set correct page of the table.
Expand Down Expand Up @@ -247,6 +259,11 @@ export default {
return;
}
// unregister change event on previous layer source if any
if (this.layer) {
this.layer.getSource().un('change', this.prepareTableDataAndColumns);
}
// reset table properties
this.records = [];
this.features = [];
Expand Down

0 comments on commit 8995f6f

Please sign in to comment.