Tag Enhancement + bugfixes

This commit is contained in:
Stefan Hardegger
2025-08-17 17:16:40 +02:00
parent 6b83783381
commit 1a99d9830d
34 changed files with 2996 additions and 97 deletions

View File

@@ -43,11 +43,27 @@ export default function TagInput({ tags, onChange, placeholder = 'Add tags...' }
return () => clearTimeout(debounce);
}, [inputValue, tags]);
const addTag = (tag: string) => {
const addTag = async (tag: string) => {
const trimmedTag = tag.trim().toLowerCase();
if (trimmedTag && !tags.includes(trimmedTag)) {
onChange([...tags, trimmedTag]);
if (!trimmedTag) return;
try {
// Resolve tag alias to canonical name
const resolvedTag = await tagApi.resolveTag(trimmedTag);
const finalTag = resolvedTag ? resolvedTag.name.toLowerCase() : trimmedTag;
// Only add if not already present
if (!tags.includes(finalTag)) {
onChange([...tags, finalTag]);
}
} catch (error) {
console.warn('Failed to resolve tag alias:', error);
// Fall back to original tag if resolution fails
if (!tags.includes(trimmedTag)) {
onChange([...tags, trimmedTag]);
}
}
setInputValue('');
setShowSuggestions(false);
setActiveSuggestionIndex(-1);