Make tagunique a more general tagaccept

* tagaccept includes what was previous done by on:blur
* on:blur in TagInput was in some cases not bubbled up to TagEditor for some reason
This commit is contained in:
Henrik Giesel 2021-06-27 18:18:59 +02:00
parent 68bbc8d25d
commit 2e00dc09d6
2 changed files with 7 additions and 14 deletions

View file

@ -194,10 +194,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
await tick();
input.setSelectionRange(0, 0);
}
function activate(index: number): void {
active = index;
}
</script>
<StickyBottom>
@ -219,25 +215,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
bind:name={tag.name}
bind:input
on:keydown={updateAutocomplete}
on:blur={() => {
destroyAutocomplete();
decideNextActive();
}}
on:tagsplit={({ detail }) =>
splitTag(tag, index, detail.start, detail.end)}
on:tagadd={() => insertTag(tag, index)}
on:tagdelete={() => deleteActiveTag(tag, index)}
on:tagunique={() => deleteActiveTagIfNotUnique(tag, index)}
on:tagjoinprevious={() => joinWithPreviousTag(tag, index)}
on:tagjoinnext={() => joinWithNextTag(tag, index)}
on:tagmoveprevious={() => moveToPreviousTag(tag, index)}
on:tagmovenext={() => moveToNextTag(tag, index)}
on:tagaccept={() => {
deleteActiveTagIfNotUnique(tag, index);
destroyAutocomplete();
decideNextActive();
}}
/>
{:else}
<Tag
name={tag.name}
bind:blink={tag.blink}
on:click={() => activate(index)}
on:click={() => (active = index)}
on:tagdelete={() => deleteTag(tag, index)}
/>
{/if}

View file

@ -81,7 +81,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
dispatch("tagdelete");
}
dispatch("tagunique");
dispatch("tagaccept");
}
function onEnter(event: Event): void {
@ -177,13 +177,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
type="text"
tabindex="-1"
size="1"
on:focus
on:blur={onBlur}
on:blur
on:keydown={onKeydown}
on:keydown
on:paste={onPaste}
on:click
/>
</label>