autocomplete on empty

This commit is contained in:
Yuri Kuznetsov
2023-09-22 14:46:14 +03:00
parent 9bbd262d05
commit fef2d74ec2
2 changed files with 20 additions and 2 deletions
+11 -1
View File
@@ -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,
+9 -1
View File
@@ -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) {