From 2e00dc09d6ef555e27a5176f096f8620d119aefb Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sun, 27 Jun 2021 18:18:59 +0200 Subject: [PATCH] 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 --- ts/editor/TagEditor.svelte | 16 ++++++---------- ts/editor/TagInput.svelte | 5 +---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index c49a812c4..a75ff325f 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -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; - } @@ -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} activate(index)} + on:click={() => (active = index)} on:tagdelete={() => deleteTag(tag, index)} /> {/if} diff --git a/ts/editor/TagInput.svelte b/ts/editor/TagInput.svelte index 2c806d8a8..8619e5c01 100644 --- a/ts/editor/TagInput.svelte +++ b/ts/editor/TagInput.svelte @@ -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 />