From 13b43d1bfaae7c46c7c1cd2efdeba0a798f7da84 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 5 Dec 2023 12:52:07 +0200 Subject: [PATCH] fix autocomplete not hiding issue --- client/src/views/email/fields/email-address-varchar.js | 7 +++++++ client/src/views/fields/link-multiple.js | 6 ++++++ client/src/views/fields/link.js | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/client/src/views/email/fields/email-address-varchar.js b/client/src/views/email/fields/email-address-varchar.js index b4555d6f95..ae66d44e57 100644 --- a/client/src/views/email/fields/email-address-varchar.js +++ b/client/src/views/email/fields/email-address-varchar.js @@ -219,6 +219,13 @@ function (Dep, From, EmailAddress) { autoSelectFirst: true, noCache: true, triggerSelectOnValidInput: false, + beforeRender: () => { + // Prevent an issue that suggestions are shown and not hidden + // when clicking outside the window and then focusing back on the document. + if (this.$input.get(0) !== document.activeElement) { + setTimeout(() => this.$input.autocomplete('hide'), 30); + } + }, formatResult: (suggestion) => { return this.getHelper().escapeString(suggestion.name) + ' <' + this.getHelper().escapeString(suggestion.id) + '>'; diff --git a/client/src/views/fields/link-multiple.js b/client/src/views/fields/link-multiple.js index a0263e340e..8160c9b7d9 100644 --- a/client/src/views/fields/link-multiple.js +++ b/client/src/views/fields/link-multiple.js @@ -529,6 +529,12 @@ class LinkMultipleFieldView extends BaseFieldView { if (this.$element.hasClass('input-sm')) { $c.addClass('small'); } + + // Prevent an issue that suggestions are shown and not hidden + // when clicking outside the window and then focusing back on the document. + if (this.$element.get(0) !== document.activeElement) { + setTimeout(() => this.$element.autocomplete('hide'), 30); + } }, formatResult: suggestion => { // noinspection JSUnresolvedReference diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.js index 3bb2828079..c4e5907d98 100644 --- a/client/src/views/fields/link.js +++ b/client/src/views/fields/link.js @@ -608,6 +608,12 @@ class LinkFieldView extends BaseFieldView { if (this.$elementName.hasClass('input-sm')) { $c.addClass('small'); } + + // Prevent an issue that suggestions are shown and not hidden + // when clicking outside the window and then focusing back on the document. + if (this.$elementName.get(0) !== document.activeElement) { + setTimeout(() => this.$elementName.autocomplete('hide'), 30); + } }, lookup: (q, callback) => { if (!this.autocompleteOnEmpty && q.length === 0) {