Skip to content
Snippets Groups Projects
Commit a0853225 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

check-in-place-select: fix a leak

Properly disconnect from the event
parent 1748ee2d
No related branches found
No related tags found
No related merge requests found
Pipeline #14281 passed
...@@ -38,6 +38,8 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) { ...@@ -38,6 +38,8 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) {
this.showReloadButton = false; this.showReloadButton = false;
this.reloadButtonTitle = ''; this.reloadButtonTitle = '';
this.showCapacity = false; this.showCapacity = false;
this._onDocumentClicked = this._onDocumentClicked.bind(this);
} }
static get scopedElements() { static get scopedElements() {
...@@ -87,17 +89,20 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) { ...@@ -87,17 +89,20 @@ export class CheckInPlaceSelect extends ScopedElementsMixin(LitElement) {
this.$select = this.$('#' + that.selectId); this.$select = this.$('#' + that.selectId);
// Close the popup when clicking outside of select2 // Close the popup when clicking outside of select2
document.addEventListener('click', (ev) => { document.addEventListener('click', this._onDocumentClicked);
if (!ev.composedPath().includes(this)) {
this._closeSelect2();
}
});
// try an init when user-interface is loaded // try an init when user-interface is loaded
this.initJSONLD(); this.initJSONLD();
} }
_closeSelect2() { disconnectedCallback() {
document.removeEventListener('click', this._onDocumentClicked);
super.disconnectedCallback();
}
_onDocumentClicked(event) {
if (event.composedPath().includes(this))
return;
const $select = this.$('#' + this.selectId); const $select = this.$('#' + this.selectId);
console.assert($select.length, "select2 missing"); console.assert($select.length, "select2 missing");
if (this.select2IsInitialized($select)) { if (this.select2IsInitialized($select)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment