docs(tag-input): add clarifying comments for non-obvious design decisions
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m26s
CI / Backend Unit Tests (pull_request) Failing after 2m44s
CI / Unit & Component Tests (push) Failing after 2m28s
CI / Backend Unit Tests (push) Failing after 25s

- SvelteMap satisfies svelte/prefer-svelte-reactivity; $derived.by() handles reactivity
- ‹›› prefix only on depth=0 context ancestors; indentation serves deeper nodes
- fetchedForQuery set after suggestions causes harmless double $derived evaluation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #251.
This commit is contained in:
Marcel
2026-04-17 12:17:22 +02:00
parent b01761d800
commit bf010a23c3

View File

@@ -23,6 +23,7 @@ let activeIndex = $state(-1);
let showSuggestions = $state(false);
const orderedSuggestions = $derived.by((): SuggestionEntry[] => {
// SvelteMap satisfies svelte/prefer-svelte-reactivity; reactivity comes from $derived.by() re-evaluation
const byId = new SvelteMap(suggestions.filter((s) => s.id).map((s) => [s.id!, s]));
const childrenOf = new SvelteMap<string, Tag[]>();
const roots: Tag[] = [];
@@ -66,6 +67,7 @@ async function fetchSuggestions(query: string) {
const currentTags = untrack(() => tags);
const currentNames = new Set(currentTags.map((t) => t.name));
suggestions = data.filter((t) => !currentNames.has(t.name));
// fetchedForQuery set after suggestions: $derived fires twice but second run is correct
fetchedForQuery = query.toLowerCase();
showSuggestions = true;
}
@@ -192,6 +194,7 @@ function handleKeydown(e: KeyboardEvent) {
onclick={() => addTag(s.tag)}
onkeydown={(e) => e.key === 'Enter' && addTag(s.tag)}
>
<!-- only on root context ancestors; depth>0 nodes rely on indentation instead -->
{#if !s.isDirectMatch && s.depth === 0}
<span class="mr-1" aria-hidden="true"></span>
{/if}