Skip to content

Commit dd69b3a

Browse files
committed
fix: allow to truncate tags
1 parent 994084c commit dd69b3a

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

packages/react/src/components/tags/BaseTag/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const BaseTag = forwardRef<HTMLDivElement, Props>(
3737
>
3838
{left}
3939
{!!text && (
40-
<span title={text} className="line-clamp-1">
40+
<span title={text} className="line-clamp-1 truncate">
4141
{text}
4242
</span>
4343
)}

packages/react/src/components/tags/F0TagDot/F0TagDot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const F0TagDot = forwardRef<HTMLDivElement, Props>(
2323
className="border-[1px] border-solid border-f1-border-secondary"
2424
left={
2525
<div
26-
className="m-1 aspect-square w-2 rounded-full"
26+
className="m-1 aspect-square h-2 w-2 rounded-full"
2727
style={{
2828
backgroundColor,
2929
}}

packages/react/src/components/tags/F0TagList/components/TagCounter.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ type Props = {
1616
export const TagCounter = ({ count, list }: Props) => {
1717
const [isOpen, setIsOpen] = useState(false)
1818

19-
const counter = <F0TagRaw text={`+${count}`} />
19+
const counter = <F0TagRaw text={`+${count}`} className="w-fit" />
2020

2121
if (!list?.length) return counter
2222

2323
return (
2424
<Popover open={isOpen} onOpenChange={setIsOpen}>
2525
<PopoverTrigger asChild>
2626
<button
27-
className={cn("inline-flex flex-shrink-0 items-center", focusRing())}
27+
className={cn(
28+
"inline-flex w-fit flex-shrink-0 items-center",
29+
focusRing()
30+
)}
2831
>
2932
{counter}
3033
</button>

packages/react/src/components/value-display/types/tagList.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,10 @@ interface TagListValue {
1313
export type TagListCellValue = TagListValue
1414

1515
export const TagListCell = (args: TagListCellValue) => (
16-
<F0TagList type={args.type} tags={args.tags as TagVariant[]} max={args.max} />
16+
<F0TagList
17+
layout="fill"
18+
type={args.type}
19+
tags={args.tags as TagVariant[]}
20+
max={args.max}
21+
/>
1722
)

packages/react/src/ui/OverflowList/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,15 @@ const OverflowList = function OverflowList<T>({
149149
)}
150150

151151
<div
152-
className="flex items-center whitespace-nowrap"
152+
className="flex min-w-0 items-center whitespace-nowrap"
153153
style={{ gap: gap > 0 ? `${gap}px` : undefined }}
154154
data-testid="overflow-visible-container"
155155
>
156156
{isInitialized &&
157157
visibleItems.map((item, index) => (
158158
<div
159159
key={`item-${index}`}
160-
className="transition-all duration-150"
160+
className="overflow-hidden transition-all duration-150"
161161
data-testid="overflow-visible-item"
162162
style={{ marginLeft: gap < 0 ? `${gap}px` : undefined }}
163163
>
@@ -176,7 +176,7 @@ const OverflowList = function OverflowList<T>({
176176
<button
177177
ref={overflowButtonRef}
178178
className={cn(
179-
"inline-flex flex-shrink-0 items-center",
179+
"inline-flex w-fit flex-shrink-0 items-center",
180180
focusRing()
181181
)}
182182
>

packages/react/src/ui/OverflowList/useOverflowCalculation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ export function useOverflowCalculation<T>(
8686
visibleCount++
8787
}
8888

89-
// Return the actual count without enforcing a minimum of 1
90-
return Math.min(visibleCount, options?.max ?? items.length)
89+
// Ensure we always show at least 1 item; it will truncate to fit
90+
const capped = Math.min(visibleCount, options?.max ?? items.length)
91+
return items.length > 0 ? Math.max(1, capped) : 0
9192
},
9293
[options?.max, items.length]
9394
)

0 commit comments

Comments
 (0)