diff --git a/client/src/views/fields/link-multiple.js b/client/src/views/fields/link-multiple.js index a7bbf203e4..88f8fedfdf 100644 --- a/client/src/views/fields/link-multiple.js +++ b/client/src/views/fields/link-multiple.js @@ -163,6 +163,14 @@ class LinkMultipleFieldView extends BaseFieldView { */ autocompleteMaxCount = null + /** + * Trigger autocomplete on empty input. + * + * @protected + * @type {boolean} + */ + autocompleteOnEmpty = false + /** * Select all attributes. * @@ -433,11 +441,13 @@ class LinkMultipleFieldView extends BaseFieldView { setTimeout(() => this.$element.autocomplete('clear'), 300); }); + const minChar = this.autocompleteOnEmpty ? 0 : 1; + this.$element.autocomplete({ serviceUrl: () => { return this.getAutocompleteUrl(); }, - minChars: 1, + minChars: minChar, paramName: 'q', noCache: true, autoSelectFirst: true, diff --git a/client/src/views/fields/link.js b/client/src/views/fields/link.js index 2e44a35e77..df21a10e3a 100644 --- a/client/src/views/fields/link.js +++ b/client/src/views/fields/link.js @@ -164,6 +164,14 @@ class LinkFieldView extends BaseFieldView { getEmptyAutocompleteResult = null + /** + * Trigger autocomplete on empty input. + * + * @protected + * @type {boolean} + */ + autocompleteOnEmpty = false + /** @inheritDoc */ events = { /** @this LinkFieldView */ @@ -536,7 +544,7 @@ class LinkFieldView extends BaseFieldView { return this.getAutocompleteUrl(q); }, lookup: (q, callback) => { - if (q.length === 0) { + if (!this.autocompleteOnEmpty && q.length === 0) { isEmptyQueryResult = true; if (this.getEmptyAutocompleteResult) {