Skip to content
Snippets Groups Projects
Commit 2c3e4e5f authored by Bekerle, Patrizio's avatar Bekerle, Patrizio :fire: Committed by Reiter, Christoph
Browse files

Prevent closing of search dropdown on loosing of focus while searching

parent e1a8d409
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ class PersonSelect extends VPULitElementJQuery {
this.selectId = 'person-select-' + commonUtils.makeId(24);
this.value = '';
this.ignoreValueUpdate = false;
this.isSearching = false;
}
static get properties() {
......@@ -88,11 +89,12 @@ class PersonSelect extends VPULitElementJQuery {
placeholder: i18n.t('person-select.placeholder'),
dropdownParent: this.$('#person-select-dropdown'),
ajax: {
delay: 250,
delay: 500,
url: apiUrl,
contentType: "application/ld+json",
beforeSend: function (jqXHR) {
jqXHR.setRequestHeader('Authorization', 'Bearer ' + window.VPUAuthToken);
that.isSearching = true;
},
data: function (params) {
return {
......@@ -113,7 +115,10 @@ class PersonSelect extends VPULitElementJQuery {
results: results
};
},
error: errorUtils.handleXhrError
error: errorUtils.handleXhrError,
complete: (jqXHR, textStatus) => {
that.isSearching = false;
}
}
}).on("select2:select", function (e) {
// set custom element attributes
......@@ -135,8 +140,17 @@ class PersonSelect extends VPULitElementJQuery {
bubbles: true
}));
}
}).on("select2:closing", (e) => {
if (that.isSearching) {
e.preventDefault();
}
});
// TODO: doesn't work here
// this.$('.select2-selection__arrow').click(() => {
// console.log("click");
// });
// preset a person
if (!ignorePreset && this.value !== '') {
const apiUrl = this.entryPointUrl + this.value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment