Skip to content
Snippets Groups Projects
Unverified Commit 9a0b6fd4 authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire:
Browse files

Fix place-selector issue that causes select2 to close immediately after opening

parent 59614bdd
No related branches found
No related tags found
No related merge requests found
Pipeline #13969 passed
...@@ -81,15 +81,11 @@ export class LocationSelect extends ScopedElementsMixin(LitElement) { ...@@ -81,15 +81,11 @@ export class LocationSelect extends ScopedElementsMixin(LitElement) {
this.updateComplete.then(()=>{ this.updateComplete.then(()=>{
that.$select = that.$('#' + that.selectId); that.$select = that.$('#' + that.selectId);
// close the selector on blur of the web component // Close the popup when clicking outside of select2
$(that).blur(() => { document.addEventListener('click', (ev) => {
// the 500ms delay is a workaround to actually get an item selected when clicking on it, if (!ev.composedPath().includes(this)) {
// because the blur gets also fired when clicking in the selector this._closeSelect2();
setTimeout(() => { }
if (this.select2IsInitialized()) {
that.$select.select2('close');
}
}, 500);
}); });
// try an init when user-interface is loaded // try an init when user-interface is loaded
...@@ -97,6 +93,14 @@ export class LocationSelect extends ScopedElementsMixin(LitElement) { ...@@ -97,6 +93,14 @@ export class LocationSelect extends ScopedElementsMixin(LitElement) {
}); });
} }
_closeSelect2() {
const $select = this.$('#' + this.selectId);
console.assert($select.length, "select2 missing");
if (this.select2IsInitialized($select)) {
$select.select2('close');
}
}
initJSONLD(ignorePreset = false) { initJSONLD(ignorePreset = false) {
const that = this; const that = this;
......
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