From 1817f52edf6c7338fce9b6b9dbeef197c9e3314e Mon Sep 17 00:00:00 2001 From: zhaoying Date: Wed, 29 Apr 2026 11:55:43 +0800 Subject: [PATCH] fix(web): ontology tag --- web/src/components/OverflowTags/index.tsx | 6 +++--- web/src/views/Ontology/index.tsx | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/components/OverflowTags/index.tsx b/web/src/components/OverflowTags/index.tsx index 9ad9cd92..82fdb2c9 100644 --- a/web/src/components/OverflowTags/index.tsx +++ b/web/src/components/OverflowTags/index.tsx @@ -3,14 +3,14 @@ import { Popover, type PopoverProps } from 'antd' import Tag, { type TagProps } from '@/components/Tag' interface OverflowTagsProps { - items: ReactNode[]; + items?: ReactNode[]; gap?: number; numTagColor?: TagProps['color']; numTag?: (num?: number) => ReactNode; popoverProps?: PopoverProps | false; } -const OverflowTags = ({ items, gap = 8, numTagColor = 'default', numTag, popoverProps }: OverflowTagsProps) => { +const OverflowTags = ({ items = [], gap = 8, numTagColor = 'default', numTag, popoverProps }: OverflowTagsProps) => { const containerRef = useRef(null) const measureRef = useRef(null) const [visibleCount, setVisibleCount] = useState(items.length) @@ -20,7 +20,7 @@ const OverflowTags = ({ items, gap = 8, numTagColor = 'default', numTag, popover if (!measure || containerWidth === 0) return const children = Array.from(measure.children) as HTMLElement[] - if (!children.length) return + if (!children.length) { setVisibleCount(0); return } // last child is the sample +N tag const extraTagWidth = (children[children.length - 1] as HTMLElement).offsetWidth diff --git a/web/src/views/Ontology/index.tsx b/web/src/views/Ontology/index.tsx index 1d4b9e94..8b29e343 100644 --- a/web/src/views/Ontology/index.tsx +++ b/web/src/views/Ontology/index.tsx @@ -166,10 +166,10 @@ const Ontology: FC = () => {
{item.scene_description}
-
+
{type}), {`+${item.type_num - 3}`}]} + items={item.entity_type ? [...item.entity_type.map((type, i) => {type}), {`+${item.type_num - 3}`}] : []} numTag={(num?: number) => {`+${item.type_num - 3 + (num ? num - 1 : 0)}`}} />