mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02: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;
|
||||
}
|
||||
|
||||
const colonAtStartOrEnd = /^:?|:?$/g;
|
||||
const withoutSingleColonAtStartOrEnd = /^:?([^:].*?[^:]):?$/;
|
||||
|
||||
function updateSuggestions(): void {
|
||||
const activeTag = tags[active!];
|
||||
|
@ -76,11 +76,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
if (autocompleteDisabled) {
|
||||
suggestionsPromise = noSuggestions;
|
||||
} else {
|
||||
const cleanedName = replaceWithColons(activeName).replace(
|
||||
colonAtStartOrEnd,
|
||||
""
|
||||
);
|
||||
suggestionsPromise = fetchSuggestions(cleanedName).then(
|
||||
const withColons = replaceWithColons(activeName);
|
||||
const withoutSingleColons = withoutSingleColonAtStartOrEnd.test(withColons)
|
||||
? withColons.replace(withoutSingleColonAtStartOrEnd, "$1")
|
||||
: withColons;
|
||||
|
||||
suggestionsPromise = fetchSuggestions(withoutSingleColons).then(
|
||||
(names: string[]): string[] => {
|
||||
autocompleteDisabled = names.length === 0;
|
||||
return names.map(replaceWithUnicodeSeparator);
|
||||
|
|
|
@ -132,6 +132,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
|
||||
await tick();
|
||||
setPosition(positionStart);
|
||||
dispatch("taginput");
|
||||
return;
|
||||
} else if (after.startsWith(":")) {
|
||||
event.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue