From f414161f178911b4a034b4f4dcc0a960424c845e Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle <patrizio.bekerle@tugraz.at> Date: Tue, 6 Aug 2019 13:21:32 +0200 Subject: [PATCH] Fix multiple blur events --- packages/person-select/src/person-select.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/person-select/src/person-select.js b/packages/person-select/src/person-select.js index 088ac456..df4e6338 100644 --- a/packages/person-select/src/person-select.js +++ b/packages/person-select/src/person-select.js @@ -33,7 +33,15 @@ class PersonSelect extends VPULitElementJQuery { this.updateComplete.then(()=>{ that.$select = that.$('#person-select'); - }) + + // 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(() => {that.$select.select2('close')}, 500); + console.log("blur"); + }); + }); } /** @@ -129,13 +137,6 @@ class PersonSelect extends VPULitElementJQuery { JSONLD.initialize(this.entryPointUrl, function (jsonld) { that.jsonld = jsonld; that.$select = that.initSelect2(); - - // 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(() => {that.$select.select2('close')}, 500); - }); }); break; } -- GitLab