diff --git a/admin-frontend/src/pages/Tags.tsx b/admin-frontend/src/pages/Tags.tsx index a349730..2327155 100644 --- a/admin-frontend/src/pages/Tags.tsx +++ b/admin-frontend/src/pages/Tags.tsx @@ -1403,6 +1403,7 @@ function PhotoTagDialog({ getPhotoTags: (photoId: number) => Promise }) { const [selectedTagName, setSelectedTagName] = useState('') + const [newTagName, setNewTagName] = useState('') const [photoTags, setPhotoTags] = useState([]) const [selectedTagIds, setSelectedTagIds] = useState>(new Set()) const [showConfirmDialog, setShowConfirmDialog] = useState(false) @@ -1421,10 +1422,36 @@ function PhotoTagDialog({ } const handleAddTag = async () => { - if (!selectedTagName.trim()) return - await onAddTag(selectedTagName.trim()) - setSelectedTagName('') - await loadPhotoTags() + // Collect both tags: selected existing tag and new tag name + const tagsToAdd: string[] = [] + + if (selectedTagName.trim()) { + tagsToAdd.push(selectedTagName.trim()) + } + + if (newTagName.trim()) { + tagsToAdd.push(newTagName.trim()) + } + + if (tagsToAdd.length === 0) { + alert('Please select a tag or enter a new tag name.') + return + } + + try { + // Add all tags (onAddTag handles creating new tags if needed) + for (const tagName of tagsToAdd) { + await onAddTag(tagName) + } + + // Clear inputs after successful tagging + setSelectedTagName('') + setNewTagName('') + await loadPhotoTags() + } catch (error) { + console.error('Failed to add tag:', error) + alert('Failed to add tag') + } } const handleRemoveTags = () => { @@ -1482,11 +1509,14 @@ function PhotoTagDialog({ {photo &&

{photo.filename}

}
-
+
+ - +

+ You can select an existing tag and enter a new tag name to add both at once. +

+
+
+ + setNewTagName(e.target.value)} + className="w-full px-3 py-2 border border-gray-300 rounded" + placeholder="Type new tag name..." + onKeyDown={(e) => { + if (e.key === 'Enter') { + handleAddTag() + } + }} + /> +

+ New tags will be created in the database automatically. +

+

+ Tags: +

{allTags.length === 0 ? (

No tags linked to this photo

) : ( @@ -1544,12 +1594,21 @@ function PhotoTagDialog({ > Remove selected tags - +
+ + +