DEV: adds an experimental `preserveKey` bool option to autocomplete (#12751)

Usage:

```
$(input).autocomplete({
  preserveKey: false
});
```

Defaults to true.
This commit is contained in:
Joffrey JAFFEUX 2021-04-19 11:40:05 +02:00 committed by GitHub
parent 92e222d246
commit 99aae959a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -85,6 +85,10 @@ export default function (options) {
return this;
}
if (options && typeof options.preserveKey === "undefined") {
options.preserveKey = true;
}
const disabled = options && options.disabled;
let wrap = null;
let autocompleteOptions = null;
@ -199,7 +203,7 @@ export default function (options) {
let text = me.val();
text =
text.substring(0, completeStart) +
(options.key || "") +
(options.preserveKey ? options.key || "" : "") +
term +
" " +
text.substring(completeEnd + 1, text.length);