Browse Source

fix tag ID consistency and auto-disable for all tag types

- Use tag.value consistently instead of reconstructing tag.type-tag.label
- Fix auto-disable to work for ALL tag types (hashtags, authors, event refs, titles, summaries)
- Each tag type now maintains separate initialization state
master
limina1 7 months ago
parent
commit
83e11192f0
  1. 7
      src/lib/navigator/EventNetwork/Legend.svelte
  2. 14
      src/lib/navigator/EventNetwork/index.svelte

7
src/lib/navigator/EventNetwork/Legend.svelte

@ -344,12 +344,11 @@ @@ -344,12 +344,11 @@
<div class="space-y-1 max-h-48 overflow-y-auto">
{#each sortedAnchors as tag}
{@const tagId = `${tag.type}-${tag.label}`}
{@const isDisabled = disabledTags.has(tagId)}
{@const isDisabled = disabledTags.has(tag.value)}
<button
class="flex items-center gap-2 w-full p-2 rounded text-left border-none bg-none cursor-pointer transition hover:bg-black/5 dark:hover:bg-white/5"
onclick={() => onTagToggle(tagId)}
onkeydown={(e) => e.key === 'Enter' || e.key === ' ' ? onTagToggle(tagId) : null}
onclick={() => onTagToggle(tag.value)}
onkeydown={(e) => e.key === 'Enter' || e.key === ' ' ? onTagToggle(tag.value) : null}
title={isDisabled ? `Click to show ${tag.label}` : `Click to hide ${tag.label}`}
aria-pressed={!isDisabled}
>

14
src/lib/navigator/EventNetwork/index.svelte

@ -168,7 +168,7 @@ @@ -168,7 +168,7 @@
let totalPersonCount = $state(0);
let displayedPersonCount = $state(0);
let hasInitializedPersons = $state(false);
let hasInitializedTags = $state(false);
let hasInitializedTags = $state(new Map<string, boolean>());
// Update dimensions when container changes
@ -302,18 +302,18 @@ @@ -302,18 +302,18 @@
value: `${n.tagType}-${n.title}`, // Use the correct tag ID format for toggling
}));
// Auto-disable all tag anchors by default (only on first time showing)
if (!hasInitializedTags && tagAnchors.length > 0) {
// Auto-disable all tag anchors by default (only on first time showing this tag type)
if (!hasInitializedTags.get(selectedTagType) && tagAnchors.length > 0) {
tagAnchorInfo.forEach(anchor => {
disabledTags.add(anchor.value);
});
hasInitializedTags = true;
hasInitializedTags.set(selectedTagType, true);
}
} else {
tagAnchorInfo = [];
// Reset initialization flag when tag anchors are hidden
if (hasInitializedTags && tagAnchorInfo.length === 0) {
hasInitializedTags = false;
// Reset initialization flag for this tag type when tag anchors are hidden
if (hasInitializedTags.get(selectedTagType) && tagAnchorInfo.length === 0) {
hasInitializedTags.set(selectedTagType, false);
}
}

Loading…
Cancel
Save