diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index 08011dfb3..289ce1309 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -45,11 +45,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeAfterBlur = null; } - function insertEmptyTagAt(index: number): void { - /* used by tag badge and tag spacer */ - tags.splice(index, 0, attachId("")); - tags = tags; - active = index; + function appendEmptyTag(): void { + // used by tag badge and tag spacer + const lastTag = tags[tags.length - 1]; + + if (!lastTag || lastTag.name.length > 0) { + tags.splice(tags.length, 0, attachId("")); + tags = tags; + } + + const tagsHadFocus = active === null; + active = null; + setActiveAfterBlur(tags.length - 1); + + if (tagsHadFocus) { + decideNextActive(); + } } function appendTagAt(index: number, name: string): void { @@ -192,7 +203,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
- insertEmptyTagAt(tags.length)} /> + insertEmptyTagAt(tags.length)} + on:click={appendEmptyTag} />