Skip to content

Commit

Permalink
Unbind the keydown event listner properly
Browse files Browse the repository at this point in the history
Otherwise, there are several listners that react to the keydown event.
  • Loading branch information
sukhwinder33445 committed Jul 4, 2024
1 parent 1a9c89e commit cffaade
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions asset/js/widget/ActionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit cffaade

Please sign in to comment.