EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
autocomplete quick enter
Yuri Kuznetsov9ce487fc9054
diff --git a/client/src/ui/autocomplete.js b/client/src/ui/autocomplete.jsindex e9b1181abb..a8b8480b94 100644--- a/client/src/ui/autocomplete.js+++ b/client/src/ui/autocomplete.js@@ -55,6 +55,7 @@ class Autocomplete {* autoSelectFirst?: boolean,* handleFocusMode?: 1|2|3,* focusOnSelect?: boolean,+ * catchFastEnter?: boolean,* }} module:ui/autocomplete~options*/@@ -66,10 +67,33 @@ class Autocomplete {/** @private */this.$element = $(element);+ let deferredEnter = false;+ let catchEnter = false;+ let catchEnterTimeout = null;+this.$element.on('keydown', e => {if (e.code === 'Tab' && !this.$element.val()) {e.stopImmediatePropagation();}++ // Scanner input.+ if (options.catchFastEnter) {+ if (e.code !== 'Enter') {+ catchEnter = true;++ if (catchEnterTimeout) {+ clearTimeout(catchEnterTimeout);+ }++ catchEnterTimeout = setTimeout(() => catchEnter = false, 40);+ }++ if (catchEnter && e.code === 'Enter' && this.$element.val()) {+ deferredEnter = true;+ } else {+ deferredEnter = false;+ }+ }});const lookup = options.lookupFunction ?@@ -119,6 +143,24 @@ class Autocomplete {e.preventDefault();});}++ if (deferredEnter) {+ setTimeout(() => {+ element.dispatchEvent(+ new KeyboardEvent("keydown", {+ key: 'Enter',+ code: 'Enter',+ keyCode: 13,+ which: 13,+ bubbles: true,+ cancelable: true+ })+ );+ }, 100);+ }++ catchEnter = false;+ deferredEnter = false;},lookup: lookup,minChars: options.minChars || 0,@@ -143,6 +185,9 @@ class Autocomplete {if (options.focusOnSelect) {this.$element.focus();}++ catchEnter = false;+ deferredEnter = false;},triggerSelectOnValidInput: options.triggerSelectOnValidInput || false,});diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.jsindex 104f8c25fa..ba583787f1 100644--- a/client/src/views/fields/link.js+++ b/client/src/views/fields/link.js@@ -709,6 +709,7 @@ class LinkFieldView extends BaseFieldView {autoSelectFirst: true,forceHide: true,triggerSelectOnValidInput: false,+ catchFastEnter: true,onSelect: item => {this.getModelFactory().create(this.foreignScope, async model => {model.set(item.attributes);