From 8fd47d0e458cd63b36a196e9b7dcda0eb0402a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabina=20Gu=C5=A1i=C4=87?= Date: Wed, 7 Jan 2026 18:22:46 +0100 Subject: [PATCH 1/2] fix: add 'untagged' tag to bookmarks without tags on creation --- frontend/components/Bookmark/NewBookmarkCard.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/components/Bookmark/NewBookmarkCard.tsx b/frontend/components/Bookmark/NewBookmarkCard.tsx index 024094f6..eb3a3db4 100644 --- a/frontend/components/Bookmark/NewBookmarkCard.tsx +++ b/frontend/components/Bookmark/NewBookmarkCard.tsx @@ -104,7 +104,7 @@ export default function NewBookmarkCard() { const handleOnSubmit = async ( submittedBmk: NewBookmarkForm, - actions: any, + actions: any ) => { // Get the last inputted string and all the tags already entered. let tags: Tag[] = strTags.map((t) => ({ title: t, id: -1 })); @@ -112,6 +112,12 @@ export default function NewBookmarkCard() { // FIXME tags.push({ title: tagInput, id: -1 }); } + + // Add default "untagged" tag if user has not provided any + if (!tags.length) { + tags = [{ title: "untagged", id: -1 }]; + } + let newBkmk: Bookmark = { id: -1, title: submittedBmk.title || submittedBmk.url, From 0e0743d06aa674c59cd127c622000f2e4c7119a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sabina=20Gu=C5=A1i=C4=87?= Date: Wed, 18 Mar 2026 09:41:28 +0100 Subject: [PATCH 2/2] refactor: derive 'untagged' tag on frontend instead of backend --- frontend/components/Bookmark/BookmarkCard.tsx | 20 ++++++++++++---- .../components/Bookmark/NewBookmarkCard.tsx | 7 +----- frontend/components/Tags/TagList.tsx | 23 +++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/frontend/components/Bookmark/BookmarkCard.tsx b/frontend/components/Bookmark/BookmarkCard.tsx index ac167cdd..998cb7f1 100644 --- a/frontend/components/Bookmark/BookmarkCard.tsx +++ b/frontend/components/Bookmark/BookmarkCard.tsx @@ -136,9 +136,12 @@ export default function BookmarkCard({ bookmark }: Readonly) { useEffect(() => { if (bookmark) { const tagList: string[] = []; - bookmark.tags.forEach((tag: Tag) => { - tagList.push(tag.title); - }); + if (bookmark.tags.length == 0) tagList.push("untagged"); + else { + bookmark.tags.forEach((tag: Tag) => { + tagList.push(tag.title); + }); + } setStrTags(tagList); } }, [bookmark]); @@ -211,7 +214,11 @@ export default function BookmarkCard({ bookmark }: Readonly) { ); } api.deleteTagById(bookmark.id, tagId); - let titles = currentBookmark.current.tags.map((t) => t.title); // just the titles display + // if there are no tags to display, display "untagged", else display the tags for the bookmark + let titles = + currentBookmark.current.tags.length !== 0 + ? currentBookmark.current.tags.map((t) => t.title) + : ["untagged"]; // just the titles display setStrTags(titles); // update the sidebar. @@ -227,7 +234,10 @@ export default function BookmarkCard({ bookmark }: Readonly) { const onPushTag = (tag: string) => addTagToBookmark(bookmark, tag).then((action) => { dispatch(action); - setStrTags([...strTags, tag]); + setStrTags((prev) => { + const cleaned = prev.filter((t) => t != "untagged"); + return [...cleaned, tag]; + }); currentBookmark.current.tags.push({ id: action.id, title: action.title }); }); diff --git a/frontend/components/Bookmark/NewBookmarkCard.tsx b/frontend/components/Bookmark/NewBookmarkCard.tsx index eb3a3db4..228ff5d3 100644 --- a/frontend/components/Bookmark/NewBookmarkCard.tsx +++ b/frontend/components/Bookmark/NewBookmarkCard.tsx @@ -104,7 +104,7 @@ export default function NewBookmarkCard() { const handleOnSubmit = async ( submittedBmk: NewBookmarkForm, - actions: any + actions: any, ) => { // Get the last inputted string and all the tags already entered. let tags: Tag[] = strTags.map((t) => ({ title: t, id: -1 })); @@ -113,11 +113,6 @@ export default function NewBookmarkCard() { tags.push({ title: tagInput, id: -1 }); } - // Add default "untagged" tag if user has not provided any - if (!tags.length) { - tags = [{ title: "untagged", id: -1 }]; - } - let newBkmk: Bookmark = { id: -1, title: submittedBmk.title || submittedBmk.url, diff --git a/frontend/components/Tags/TagList.tsx b/frontend/components/Tags/TagList.tsx index 48ebb851..2888b042 100644 --- a/frontend/components/Tags/TagList.tsx +++ b/frontend/components/Tags/TagList.tsx @@ -9,12 +9,19 @@ import itemStyle from "./tag-list-item.module.scss"; import menuStyle from "styles/tag.module.scss"; import { useSelectedTags } from "@/contexts/SelectedContext"; import { useScreenSize } from "@/contexts/ScreenSizeContext"; +import { useBookmarks } from "@/contexts/BookmarkContext"; // import bookmarks for the "untagged" tag + const TagList = () => { const userAuth = useAuth(); const tagMap = useTags(); const [loading, setLoading] = useState(false); const { selected, setSelected } = useSelectedTags(); const isPC = useScreenSize(); + const bookmark = useBookmarks(); + // check if at least one bookmark has no tags + const hasUntaggedBookmark = bookmark.fetchedBookmarks.some( + (t) => t.tags.length === 0, + ); useEffect(() => { if (userAuth && tagMap.size == 0) { setLoading(true); @@ -51,6 +58,22 @@ const TagList = () => { } let groupItems: any = []; + // adds "untagged" tag to the tag list + if (hasUntaggedBookmark) { + groupItems.push( + + + , + ); + } tagMap.forEach((tagCnt) => { groupItems.push(