mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix suggestions not showing when typing space in a TagInput
This commit is contained in:
parent
b502ceedca
commit
9f56d51811
2 changed files with 8 additions and 6 deletions
|
@ -65,7 +65,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
return response.tags;
|
return response.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
const colonAtStartOrEnd = /^:?|:?$/g;
|
const withoutSingleColonAtStartOrEnd = /^:?([^:].*?[^:]):?$/;
|
||||||
|
|
||||||
function updateSuggestions(): void {
|
function updateSuggestions(): void {
|
||||||
const activeTag = tags[active!];
|
const activeTag = tags[active!];
|
||||||
|
@ -76,11 +76,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
if (autocompleteDisabled) {
|
if (autocompleteDisabled) {
|
||||||
suggestionsPromise = noSuggestions;
|
suggestionsPromise = noSuggestions;
|
||||||
} else {
|
} else {
|
||||||
const cleanedName = replaceWithColons(activeName).replace(
|
const withColons = replaceWithColons(activeName);
|
||||||
colonAtStartOrEnd,
|
const withoutSingleColons = withoutSingleColonAtStartOrEnd.test(withColons)
|
||||||
""
|
? withColons.replace(withoutSingleColonAtStartOrEnd, "$1")
|
||||||
);
|
: withColons;
|
||||||
suggestionsPromise = fetchSuggestions(cleanedName).then(
|
|
||||||
|
suggestionsPromise = fetchSuggestions(withoutSingleColons).then(
|
||||||
(names: string[]): string[] => {
|
(names: string[]): string[] => {
|
||||||
autocompleteDisabled = names.length === 0;
|
autocompleteDisabled = names.length === 0;
|
||||||
return names.map(replaceWithUnicodeSeparator);
|
return names.map(replaceWithUnicodeSeparator);
|
||||||
|
|
|
@ -132,6 +132,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
await tick();
|
await tick();
|
||||||
setPosition(positionStart);
|
setPosition(positionStart);
|
||||||
|
dispatch("taginput");
|
||||||
return;
|
return;
|
||||||
} else if (after.startsWith(":")) {
|
} else if (after.startsWith(":")) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
Loading…
Reference in a new issue