Skip to content

Commit b1e8193

Browse files
fix(tables): unsubscribe the row deselect handler on unmount
subscribe and unsubscribe were both handed a freshly created arrow function, so the two never matched and the handler outlived the component. Every table that had been mounted kept answering the event, deselecting rows in tables the user had already navigated away from. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent 357165b commit b1e8193

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/shared/components/ncTable/sections/CustomTable.vue‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,14 @@ export default {
315315
this.pendingTitleMeasure = window.requestAnimationFrame(() => this.updateCardTitleLines())
316316
})
317317
this.$nextTick(() => this.observeCardLayout())
318-
subscribe('tables:selected-rows:deselect', ({ elementId, isView }) => this.deselectAllRows(elementId, isView))
318+
subscribe('tables:selected-rows:deselect', this.handleDeselectAllRows)
319319
subscribe('tables:row:animate', this.enableRowAnimation)
320320
subscribe(PAGINATION_CHANGED, this.handlePaginationChanged)
321321
},
322322
beforeUnmount() {
323323
window.cancelAnimationFrame(this.pendingTitleMeasure)
324324
this.cardResizeObserver?.disconnect()
325-
unsubscribe('tables:selected-rows:deselect', ({ elementId, isView }) => this.deselectAllRows(elementId, isView))
325+
unsubscribe('tables:selected-rows:deselect', this.handleDeselectAllRows)
326326
unsubscribe('tables:row:animate', this.enableRowAnimation)
327327
unsubscribe(PAGINATION_CHANGED, this.handlePaginationChanged)
328328
},
@@ -391,6 +391,11 @@ export default {
391391
this.rowsPerPage = payload.rowsPerPage
392392
}
393393
},
394+
// A named handler, so beforeUnmount can actually remove it: unsubscribe compares by
395+
// reference and a fresh arrow function never matches the one that was subscribed.
396+
handleDeselectAllRows({ elementId, isView }) {
397+
this.deselectAllRows(elementId, isView)
398+
},
394399
deselectAllRows(elementId, isView) {
395400
if (parseInt(elementId) === parseInt(this.elementId) && isView === this.isView) {
396401
this.selectedRows = []

0 commit comments

Comments
 (0)