Skip to content

Commit 3306b1c

Browse files
JasonW404jason
andauthored
fix: add missing Popover import in DetailHeader (#476)
* fix: add missing Popover import in DetailHeader The TagsInline component uses Popover to display hidden tags when they overflow the container width, but Popover was not imported from antd. This caused a runtime error when datasets had many tags (>5), triggering ErrorBoundary and redirecting users to homepage. Root cause: Line 3 imported Card, Button, Tag, Tooltip, Modal but missing Popover, while Popover was used at lines 193-215. Fix: Add Popover to the antd import statement. * fix: correct Tag id type from number to string (UUID) The backend returns Tag objects with UUID string IDs, but frontend components AddTagPopover and DetailHeader defined Tag interface with id: number, causing type mismatch and potential display issues. Changes: - AddTagPopover.tsx: interface Tag { id: number } → { id: string } - DetailHeader.tsx: TagConfig and TagsInline interfaces updated to id: string This aligns with: - Backend: TagResponse.java returns UUID string - dataset.model.ts: TagItem interface already correctly defines id: string --------- Co-authored-by: jason <jason@example.com>
1 parent 7f61ca5 commit 3306b1c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

frontend/src/components/AddTagPopover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useState } from "react";
44
import { useTranslation } from "react-i18next";
55

66
interface Tag {
7-
id: number;
7+
id: string;
88
name: string;
99
color: string;
1010
}

frontend/src/components/DetailHeader.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useLayoutEffect, useEffect, useRef, useState, useCallback, useMemo } from "react";
22
import { Database } from "lucide-react";
3-
import { Card, Button, Tag, Tooltip, Modal } from "antd";
3+
import { Card, Button, Tag, Tooltip, Modal, Popover } from "antd";
44
import type { ItemType } from "antd/es/menu/interface";
55
import AddTagPopover from "./AddTagPopover";
66
import ActionDropdown from "./ActionDropdown";
@@ -32,9 +32,9 @@ interface OperationItem {
3232

3333
interface TagConfig {
3434
showAdd: boolean;
35-
tags: Array<{ id: number; name: string; color: string } | string>;
35+
tags: Array<{ id: string; name: string; color: string } | string>;
3636
onFetchTags?: () => Promise<{
37-
data: { id: number; name: string; color: string }[];
37+
data: { id: string; name: string; color: string }[];
3838
}>;
3939
onAddTag?: (tag: string) => void;
4040
onCreateAndTag?: (tagName: string) => void;
@@ -48,7 +48,7 @@ interface DetailHeaderProps<T> {
4848
}
4949

5050
// 标签单行渲染组件
51-
const TagsInline = ({ tags }: { tags: Array<{ id: number; name: string; color: string } | string> }) => {
51+
const TagsInline = ({ tags }: { tags: Array<{ id: string; name: string; color: string } | string> }) => {
5252
const containerRef = useRef<HTMLDivElement>(null);
5353
const tagsAreaRef = useRef<HTMLDivElement>(null);
5454
const [visibleTags, setVisibleTags] = useState<typeof tags>([]);

0 commit comments

Comments
 (0)