diff --git a/packages/person-select/person-select.js b/packages/person-select/person-select.js index de96996cb677cc15b1d0e56276f82f0f364d3726..62aa29c8b405fd96b896fbf1bdda94c50ea24f1c 100644 --- a/packages/person-select/person-select.js +++ b/packages/person-select/person-select.js @@ -43,7 +43,9 @@ class PersonSelect extends VPULitElement { "text": "http://schema.org/name" }; - that.$('#person-select').select2({ + const $select = that.$('#person-select'); + + $select.select2({ width: '100%', language: that.lang === "de" ? select2LangDe() : select2LangEn(), minimumInputLength: 2, @@ -93,6 +95,13 @@ class PersonSelect extends VPULitElement { bubbles: true })); }); + + // close the selector on blur of the web component + $(that).blur(() => { + // the 500ms delay is a workaround to actually get an item selected when clicking on it, + // because the blur gets also fired when clicking in the selector + setTimeout(() => {$select.select2('close')}, 500); + }); }); }) }