Fix TagBadge and TagSpacer + shortcut

This commit is contained in:
Henrik Giesel 2021-06-27 17:03:12 +02:00
parent 0acbf3e9eb
commit 547e6f16c6

View file

@ -45,11 +45,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
activeAfterBlur = null; activeAfterBlur = null;
} }
function insertEmptyTagAt(index: number): void { function appendEmptyTag(): void {
/* used by tag badge and tag spacer */ // used by tag badge and tag spacer
tags.splice(index, 0, attachId("")); const lastTag = tags[tags.length - 1];
tags = tags;
active = index; 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 { 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
<StickyBottom> <StickyBottom>
<div class="row-gap"> <div class="row-gap">
<ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}> <ButtonToolbar class="dropup d-flex flex-wrap align-items-center" {size}>
<AddTagBadge on:click={() => insertEmptyTagAt(tags.length)} /> <AddTagBadge on:click={appendEmptyTag} />
<TagAutocomplete <TagAutocomplete
class="d-flex flex-column-reverse" class="d-flex flex-column-reverse"
@ -236,7 +247,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<div <div
class="tag-spacer flex-grow-1 align-self-stretch" class="tag-spacer flex-grow-1 align-self-stretch"
on:click={() => insertEmptyTagAt(tags.length)} on:click={appendEmptyTag}
/> />
</TagAutocomplete> </TagAutocomplete>