From d623abd20c070b7736f66793b8f921a0ad7cb27f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 7 Sep 2025 16:00:03 +0000 Subject: fix: fix tag flicker caused by tag sorting --- .../web/components/dashboard/bookmarks/TagList.tsx | 32 ++++++++++------------ .../components/dashboard/bookmarks/TagsEditor.tsx | 21 +++++++------- 2 files changed, 24 insertions(+), 29 deletions(-) (limited to 'apps/web/components/dashboard/bookmarks') diff --git a/apps/web/components/dashboard/bookmarks/TagList.tsx b/apps/web/components/dashboard/bookmarks/TagList.tsx index e8bed9eb..593a269b 100644 --- a/apps/web/components/dashboard/bookmarks/TagList.tsx +++ b/apps/web/components/dashboard/bookmarks/TagList.tsx @@ -24,24 +24,20 @@ export default function TagList({ } return ( <> - {bookmark.tags - .sort((a, b) => - a.attachedBy === "ai" ? 1 : b.attachedBy === "ai" ? -1 : 0, - ) - .map((t) => ( -
- - {t.name} - -
- ))} + {bookmark.tags.map((t) => ( +
+ + {t.name} + +
+ ))} ); } diff --git a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx b/apps/web/components/dashboard/bookmarks/TagsEditor.tsx index 1893c2a6..f80ba963 100644 --- a/apps/web/components/dashboard/bookmarks/TagsEditor.tsx +++ b/apps/web/components/dashboard/bookmarks/TagsEditor.tsx @@ -31,9 +31,11 @@ export function TagsEditor({ const [optimisticTags, setOptimisticTags] = useState(_tags); const { data: existingTags, isLoading: isExistingTagsLoading } = - api.tags.list.useQuery(); - - existingTags?.tags.sort((a, b) => a.name.localeCompare(b.name)); + api.tags.list.useQuery(undefined, { + select: (data) => ({ + tags: data.tags.sort((a, b) => a.name.localeCompare(b.name)), + }), + }); const onChange = ( _option: readonly EditableTag[], @@ -96,14 +98,11 @@ export function TagsEditor({ attachedBy: "human" as const, })) ?? [] } - value={optimisticTags - .slice() - .sort((a) => (a.attachedBy === "human" ? -1 : 1)) - .map((t) => ({ - label: t.name, - value: t.id, - attachedBy: t.attachedBy, - }))} + value={optimisticTags.slice().map((t) => ({ + label: t.name, + value: t.id, + attachedBy: t.attachedBy, + }))} isMulti closeMenuOnSelect={false} isClearable={false} -- cgit v1.2.3-70-g09d2