From cffaadefcdfe233c7196eea9fa01c613a9938b5e Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Thu, 4 Jul 2024 11:16:10 +0200 Subject: [PATCH] Unbind the keydown event listner properly Otherwise, there are several listners that react to the keydown event. --- asset/js/widget/ActionList.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/asset/js/widget/ActionList.js b/asset/js/widget/ActionList.js index 61ac7a2b..1ca1051d 100644 --- a/asset/js/widget/ActionList.js +++ b/asset/js/widget/ActionList.js @@ -16,15 +16,25 @@ define(["../notjQuery"], function (notjQuery) { bind() { notjQuery(this.list).on('click', `${LIST_IDENTIFIER} ${LIST_ITEM_IDENTIFIER}, ${LIST_IDENTIFIER} ${LIST_ITEM_IDENTIFIER} a[href]`, this.onClick, this); + this.bindedKeyDown = this.onKeyDown.bind(this) + document.body.addEventListener('keydown', this.bindedKeyDown); + return this; } + unbind() { + document.body.removeEventListener('keydown', this.bindedKeyDown); + this.bindedKeyDown = null; + } + refresh(list, detailUrl = null) { if (list === this.list) { // If the DOM node is still the same, nothing has changed return; } + this.unbind(); + this.list = list; this.bind();