Skip to content

Commit 8995f6f

Browse files
committed
Unregister events properly when layer changes and / or component is closed
1 parent fe48724 commit 8995f6f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/attributeTable/AttributeTable.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export default {
8888
// unregister event after table is closed
8989
this.layer.getSource().un('change', this.prepareTableDataAndColumns);
9090
}
91+
92+
if (this.syncTableMapSelection) {
93+
this.deactivateSelectRowOnMapClick();
94+
}
9195
},
9296
watch: {
9397
layerId () {
@@ -172,6 +176,14 @@ export default {
172176
});
173177
},
174178
179+
/**
180+
* Deactivate behaviour that a selected feature on the
181+
* map will be selected in the AttributeTable as well.
182+
*/
183+
deactivateSelectRowOnMapClick () {
184+
WguEventBus.$off('map-selectionchange');
185+
},
186+
175187
/**
176188
* Highlight row matching the feature ID
177189
* and set correct page of the table.
@@ -247,6 +259,11 @@ export default {
247259
return;
248260
}
249261
262+
// unregister change event on previous layer source if any
263+
if (this.layer) {
264+
this.layer.getSource().un('change', this.prepareTableDataAndColumns);
265+
}
266+
250267
// reset table properties
251268
this.records = [];
252269
this.features = [];

0 commit comments

Comments
 (0)