Fixed issue with suggestions on multiple terms
This commit is contained in:
parent
c6f27b1ade
commit
d2019d3a09
1 changed files with 6 additions and 5 deletions
|
@ -48,18 +48,19 @@ function createAwesompleteInstance(element, separator, tags = []) {
|
||||||
// Tags are separated by separator. Ignore leading search flags
|
// Tags are separated by separator. Ignore leading search flags
|
||||||
awesome.filter = (text, input) => {
|
awesome.filter = (text, input) => {
|
||||||
let filterFunc = Awesomplete.FILTER_CONTAINS;
|
let filterFunc = Awesomplete.FILTER_CONTAINS;
|
||||||
const inputFlagged = input.replace(/^[-~+]/, '');
|
let term = input.match(new RegExp(`[^${separator}]*$`))[0];
|
||||||
if (input !== inputFlagged) {
|
const termFlagged = term.replace(/^[-~+]/, '');
|
||||||
input = inputFlagged;
|
if (term !== termFlagged) {
|
||||||
|
term = termFlagged;
|
||||||
filterFunc = Awesomplete.FILTER_STARTSWITH;
|
filterFunc = Awesomplete.FILTER_STARTSWITH;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filterFunc(text, input.match(new RegExp(`[^${separator}]*$`))[0]);
|
return filterFunc(text, term);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Insert new selected tag in the input
|
// Insert new selected tag in the input
|
||||||
awesome.replace = (text) => {
|
awesome.replace = (text) => {
|
||||||
const before = awesome.input.value.match(new RegExp(`^.+${separator}+|`))[0];
|
const before = awesome.input.value.match(new RegExp(`^(.+${separator}+)?[-~+]?|`))[0];
|
||||||
awesome.input.value = `${before}${text}${separator}`;
|
awesome.input.value = `${before}${text}${separator}`;
|
||||||
};
|
};
|
||||||
// Highlight found items
|
// Highlight found items
|
||||||
|
|
Loading…
Reference in a new issue