Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Show every tag inline when the last tag is narrower than the overflow…
… counter

TagBadgeGroup sizes itself to the width of its tags, then fits tags into that width. The fit loop stopped at the first tag that did not fit next to the `+N` counter, so when the last tag was narrower than the counter (short tags such as `eu` or `v1`) the group showed only `+2` even though every tag fit. Keep looking past that tag so the last one can be placed without the counter.
  • Loading branch information
burrows99 committed Nov 22, 2026
commit 74b7860b58a57d329be555e31e883126528c5993
13 changes: 13 additions & 0 deletions ui-v2/src/components/ui/tag-badge-group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ describe("TagBadgeGroup", () => {
);
});

it("shows every tag when they fit, even if the counter is wider than the last tag", () => {
// the group sizes itself to its tags (120); the 70px counter would not
// fit next to the first tag, but it is not needed when both tags fit
restoreLayout = mockLayout(120, () => 70);
render(<TagBadgeGroup tags={["alpha", "beta"]} />);

expect(getVisibleTag("alpha")).toBeVisible();
expect(getVisibleTag("beta")).toBeVisible();
expect(
screen.queryByRole("button", { name: /more tags/i }),
).not.toBeInTheDocument();
});

it("measures duplicate tags independently", () => {
// 2 tags (120) + overflow (30) fit in 160
restoreLayout = mockLayout(160);
Expand Down
10 changes: 5 additions & 5 deletions ui-v2/src/components/ui/tag-badge-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ export const TagBadgeGroup = ({
const widths = tags.map((_, i) => widthOf(tagRefs.current.get(i)));
let used = 0;
let count = 0;
// No early exit: a tag that does not fit next to the `+N` counter can
Comment thread
burrows99 marked this conversation as resolved.
Resolved
// still fit when it is the last tag and the counter is not shown.
for (let i = 0; i < cap; i++) {
used += widths[i];
const hasOverflow = i + 1 < tags.length;
const needed = used + widths[i] + (hasOverflow ? overflowWidth : 0);
if (needed > available) {
break;
if (used + (hasOverflow ? overflowWidth : 0) <= available) {
count = i + 1;
}
used += widths[i];
count = i + 1;
}
setVisibleCount(count);
setFullWidth(
Expand Down
Loading