From 2a10d1a2360cb01d0a91ecb6a9afb21c87d0608b Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 27 Jun 2021 17:03:12 +0200 Subject: [PATCH] Fix TagBadge and TagSpacer + shortcut --- ts/editor/TagEditor.svelte | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) 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} />