fix: remove deleted tags from filter automatically
When a tag is deleted as orphaned, it's now automatically removed from the active filter selection. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
// Transform tags to Svelecte format
|
||||
let tagOptions = $derived(availableTags.map((t) => ({ value: t.name, label: t.name })));
|
||||
let availableTagNames = $derived(new Set(availableTags.map((t) => t.name.toLowerCase())));
|
||||
|
||||
// Track selected tag names for Svelecte
|
||||
let selectedTagNames = $state(filters.tags);
|
||||
@@ -22,6 +23,14 @@
|
||||
selectedTagNames = filters.tags;
|
||||
});
|
||||
|
||||
// Remove deleted tags from filter when availableTags changes
|
||||
$effect(() => {
|
||||
const validTags = filters.tags.filter((t) => availableTagNames.has(t.toLowerCase()));
|
||||
if (validTags.length !== filters.tags.length) {
|
||||
onchange({ ...filters, tags: validTags });
|
||||
}
|
||||
});
|
||||
|
||||
function handleTypeChange(newType: 'task' | 'thought' | 'all') {
|
||||
onchange({ ...filters, type: newType });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user