mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 04:50:59 +00:00
fix(ui): let a truncating label actually truncate
A span marked both shrink-0 and truncate never gives up width, so a long source name on a collapsed priority group squeezed the metric label at phone width, and a long month marker in the document flow could overrun its cell. Both shrink now and cut with an ellipsis.
This commit is contained in:
1 parent
8f5b5d6e54
commit
c1144b3c4c
3 files changed
+19
-2
No files matched your search
@@ -76,7 +76,7 @@ function FlowMonthMarker({ label }: { label: string }) {
|
||||
data-slot="document-flow-month"
|
||||
className="absolute inset-x-0 -top-6 flex h-6 items-center gap-2"
|
||||
>
|
||||
<span className="text-muted-foreground shrink-0 truncate text-xs font-medium tracking-wide uppercase">
|
||||
<span className="text-muted-foreground min-w-0 truncate text-xs font-medium tracking-wide uppercase">
|
||||
{label}
|
||||
</span>
|
||||
<span aria-hidden className="bg-border h-px flex-1" />
|
||||
|
||||
@@ -54,6 +54,17 @@ describe("Settings → Source priority, sources in use", () => {
|
||||
for (const id of controls) expect(html).toContain(`id="${id}"`);
|
||||
});
|
||||
|
||||
it("lets a collapsed group's winner truncate instead of squeezing the label", () => {
|
||||
const html = render(["WITHINGS", "MANUAL"]);
|
||||
const winner = html.match(
|
||||
/data-slot="sources-metric-winner" class="([^"]*)"/,
|
||||
)?.[1];
|
||||
expect(winner).toBeDefined();
|
||||
expect(winner).toMatch(/\btruncate\b/);
|
||||
expect(winner).toMatch(/\bmin-w-0\b/);
|
||||
expect(winner).not.toMatch(/\bshrink-0\b/);
|
||||
});
|
||||
|
||||
it("says so when no source is in use at all", () => {
|
||||
expect(render([])).toContain('data-testid="sources-none-in-use"');
|
||||
});
|
||||
|
||||
@@ -415,7 +415,13 @@ export function SourcesSection() {
|
||||
</span>
|
||||
{/* Collapsed, the group still says who wins. */}
|
||||
{!open && list[0] ? (
|
||||
<span className="text-muted-foreground shrink-0 truncate text-xs">
|
||||
<span
|
||||
data-slot="sources-metric-winner"
|
||||
// `truncate` needs room to give up: a shrink-0 span
|
||||
// never cut, and a long source name squeezed the
|
||||
// metric label at 390 px instead.
|
||||
className="text-muted-foreground max-w-[45%] min-w-0 truncate text-xs"
|
||||
>
|
||||
{t(MEASUREMENT_SOURCE_SETTINGS_LABEL_KEYS[list[0]])}
|
||||
</span>
|
||||
) : null}
|
||||
|
||||
Reference in new issue
Block a user