diff --git a/frontend/src/v2/lib/primitives/RChip/RChip.stories.ts b/frontend/src/v2/lib/primitives/RChip/RChip.stories.ts index da27600e0..486b43994 100644 --- a/frontend/src/v2/lib/primitives/RChip/RChip.stories.ts +++ b/frontend/src/v2/lib/primitives/RChip/RChip.stories.ts @@ -1,7 +1,27 @@ import type { Meta, StoryObj } from "@storybook/vue3-vite"; +import { expect } from "storybook/test"; import { ref } from "vue"; import RChip from "./RChip.vue"; +/** Strings that expose descenders, ascenders, and mixed scripts in tight pills. */ +const TYPOGRAPHY_FIXTURES = [ + "gjpqy", + "Typography", + "Ångström", + "niño", + "日本語", + "9999+", + "Co-op", +] as const; + +const CHIP_SIZES = ["x-small", "small", "default", "large", "x-large"] as const; + +function textBounds(content: Element): DOMRect { + const range = document.createRange(); + range.selectNodeContents(content); + return range.getBoundingClientRect(); +} + const meta: Meta = { title: "Primitives/RChip", component: RChip, @@ -240,6 +260,83 @@ export const Disabled: Story = { }), }; +// ── Typography ───────────────────────────────────────────────────── + +export const TypographyDescenders: Story = { + name: "Typography · descenders & special characters", + render: () => ({ + components: { RChip }, + setup: () => ({ + rowLabels: [...TYPOGRAPHY_FIXTURES], + sizes: CHIP_SIZES, + }), + template: ` +
+

+ Fixture strings for descenders, ascenders, and mixed scripts across the + size ladder (translucent · primary). +

+
+ + {{ size }} + + + {{ label }} + +
+
+ closable + + {{ label }} + +
+
+ `, + }), + play: async ({ canvasElement, step }) => { + await step("chip text fits inside the pill vertically", async () => { + const chips = Array.from( + canvasElement.querySelectorAll('[data-testid="typography-chip"]'), + ); + expect(chips.length).toBeGreaterThan(0); + + for (const chip of chips) { + const content = chip.querySelector(".r-chip__content"); + expect(content).not.toBeNull(); + if (!content?.textContent?.trim()) continue; + + const chipRect = chip.getBoundingClientRect(); + const textRect = textBounds(content); + const pad = 1; + + expect(textRect.top).toBeGreaterThanOrEqual(chipRect.top - pad); + expect(textRect.bottom).toBeLessThanOrEqual(chipRect.bottom + pad); + } + }); + }, +}; + // ── Real-world ────────────────────────────────────────────────────── export const GalleryTags: Story = { diff --git a/frontend/src/v2/lib/primitives/RChip/RChip.vue b/frontend/src/v2/lib/primitives/RChip/RChip.vue index e5063f269..7cad5d76d 100644 --- a/frontend/src/v2/lib/primitives/RChip/RChip.vue +++ b/frontend/src/v2/lib/primitives/RChip/RChip.vue @@ -185,10 +185,10 @@ function onClose(evt: MouseEvent) { pointer-events: none; } +/* No overflow:hidden — it clips descenders in the fixed-height ladder. */ .r-chip__content { min-width: 0; - overflow: hidden; - text-overflow: ellipsis; + line-height: 1.2; /* below inherited line box so descenders fit fixed heights */ } .r-chip__icon {