Skip to content

Commit 9c70c16

Browse files
fix(ui): record:path uses the compact path in a narrow record drawer, keyed on its own width (#34696) (#34737)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX Fixes #34696 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:阶段路径(`record:path`)的桌面行 / 紧凑路径切换,从只看视口改为「视口 ≥ sm 且路径自身宽度 ≥ 24rem」才画桌面行,否则画 #34595 的紧凑路径。 - 为什么改:1280px 视口下打开 380px 记录抽屉时,七个阶段各只剩约 33px,标签被截成一个字母,销售在抽屉里看不出商机处在哪一步。 - 风险与回滚:纯 CSS(Tailwind 容器查询),无元数据、无新 prop、无新文案;宽路径(900/1200px)的桌面行与旧切换逐像素一致(e2e fixture 对照实测)。阈值依据「最窄整页约 464px」是读样式类推算的,未在运行中的 Console 实测。回滚即 revert 本 PR。 - 先看:`ui/packages/plugin-detail/src/renderers/record-path.tsx`(根 `@container` 与两行的 `sm:@sm:` 类);`ui/e2e/record-path-narrow-drawer-34696.spec.ts`。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-detail/src/renderers/__tests__/record-path.compact-34595.test.tsx`,预期 10 条全绿(含「根是两行共同查询的容器」「两行都不再只按视口切换」);几何见 CI 的 Build & E2E UI 里 `record-path-narrow-drawer-34696.spec.ts` 的 6 条。 - 需要你做的:无,席位落地。 ## What changes - `record-path.tsx`: the path's root is now a Tailwind `@container`, and each row stacks the viewport variant on a container variant. The desktop row is `hidden sm:@sm:flex` (was `hidden sm:flex`); the compact path is `sm:@sm:hidden` (was `sm:hidden`). So the desktop row draws only when the viewport is at least `sm` AND the path itself is at least `@sm` (24rem, 384 px) wide; otherwise the compact path from #34595 draws. - Below `sm` nothing changes: the compact path, whatever the path's width. - **Pattern followed:** Tailwind container queries, as `HeaderHighlight.tsx` (`@container` + `@lg:grid-cols-3`) and `DetailSection.tsx` (`@container` + `@sm:grid-cols-2`) do in the same package. Not the `ResizeObserver` measure of `RecordTabRow.tsx` / `RelatedList.tsx`: those measure *overflow*, which CSS cannot express; this decision is a pure width threshold, so CSS gets it right on the first paint, with no state, no re-render and nothing for jsdom to fake. - **Threshold:** 24rem. Reasoning, READ from classes and NOT measured in a running Console: at or above `sm`, the narrowest full-width record page should be a 768 px viewport beside the expanded `16rem` sidebar (`SIDEBAR_WIDTH`), inside the layout shell's `md:p-6`, so about 464 px before any inner padding, above 384. A 380 px drawer (the drawer's documented floor is 360 px) gives the path at most 380 px, under 384. `@md` (28rem, 448 px) was rejected because it sits only 16 px under that estimate. MEASURED (fixture, Chromium): 360 px and 380 px paths at a 1280 px viewport draw the compact path; 900 px and 1200 px paths draw the desktop row, pixel-identical to the old switch. - Tests: two existing assertions that pinned the viewport-only class names (`record-path.compact-34595.test.tsx`, `record-path.phoneRow-26897.test.tsx`) now pin the stacked names, citing #34696; a new top-level `describe` in `record-path.compact-34595.test.tsx` pins that the root is the container both rows query and that neither row switches on the viewport alone. `e2e/record-path-phone-row.spec.ts` now grabs the compact class by its new token. - New `ui/e2e/record-path-narrow-drawer-34696.spec.ts`: Chromium geometry with real Tailwind compiled for the classes read out of `record-path.tsx`. - Changeset: `@object-ui/plugin-detail` patch. ## Why #34614's acceptance 1 asks that a 380 px drawer show no label cut to one letter. The ~33 px labels reading 'P…', 'Pro…', 'Ne…' were measured by o3-A on the real record drawer (os-dev report 6941211681 on #34614); this run did NOT re-measure the real drawer. Premise lines, measured by this run: - **Cause (read at origin/main `77b42a1ed0`, unchanged at `f6f5b50a05`):** `record-path.tsx` switched by viewport only: the desktop row's class `hidden sm:flex w-full items-start gap-2`, stages `flex-1 min-w-0`, ordinary labels `text-center truncate`; the compact block's class `sm:hidden w-full`. Holds. Correction: the card spells the compact class `flex sm:hidden` and its line addresses predate #34684; the substance is unchanged. - **Repro (fixture, Chromium, real Tailwind, 1280 px viewport, desktop row forced on in a 380 px path):** every ordinary stage gets under 50 px (Prospecting 46.84 px) and Prospecting, Qualification, Needs Analysis and Negotiation are cut; Proposal fits whole. So in a bare 380 px path the cut is to a few letters; the card's one-letter cut matches a narrower path (the drawer body's own padding), which this run did not measure. - **Prior rulings:** `node scripts/pm/check-prior-rulings.mjs --card 34696 --terms 'container query,@container,narrow drawer,record path,record-path,viewport,breakpoint'` at `f6f5b50a05`: 1 hit, ADR-0065 Decision §2 ("Authors never write breakpoint variant classes"). It rules on author-written metadata styling; this diff changes renderer-internal classes and no metadata, so it does not apply. Card thread: 0 rulings. - **Reach:** the Console's record drawer at a desktop viewport, per the card and o3-A's report; not re-measured live by this run. ## Tests <details><summary>Unit: plugin-detail package, typecheck</summary> ``` $ pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/ Test Files 382 passed | 1 skipped (383) Tests 3442 passed | 18 skipped (3460) TEST_EXIT=0 $ pnpm --filter @object-ui/plugin-detail type-check > tsc --noEmit && tsc -p tsconfig.test.json TC_EXIT=0 ``` Run after `pnpm exec turbo run build --filter='@object-ui/plugin-detail^...' --concurrency=2` (BUILD_EXIT=0), on a tree whose package files are byte-identical to the head (later commits touch only the changeset and the e2e spec). </details> <details><summary>E2E: the new spec and the phone-row spec, Chromium</summary> ``` $ pnpm exec playwright test (scratch config: the two specs, chromium, /opt/pw-browsers/chromium) ✓ record-path-phone-row.spec.ts: 320px / 375px / 390px, long name wraps, twenty-stage path (5) ✓ the defect this pins: at 380px the desktop row gives each stage under 50px and cuts the long names ✓ a 360px drawer at a 1280px viewport draws the compact path, the current stage whole ✓ a 380px drawer at a 1280px viewport draws the compact path, the current stage whole ✓ a viewport below `sm` keeps the compact path even in a path wider than `@sm` ✓ CONTROL — a 900px path at a 1280px viewport draws the desktop row, every label readable ✓ CONTROL — the wide desktop row is pixel-identical to the viewport-only switch it replaces 11 passed (2.9s) os-verify-lock: VERDICT command-exit 0 ``` The pixel-identity control renders the same fixture twice, once with the old classes (`hidden sm:flex` / `sm:hidden`, no container) and once with the new, at 900 px and 1200 px paths, and asserts every label's width, top and left are equal. The defect leg forces the desktop row on at 380 px so the narrow-drawer legs are not vacuous. </details> <details><summary>Ablation (one pin)</summary> Mutation: drop `@container` from the root (`cn('@container w-full', className)` to `cn('w-full', className)`), via `scripts/ablation-replace.mjs`. ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob f8facc4 -> aa1439ba95c7 × the root is the container both rows query, with no container between Tests 1 failed | 9 passed (10) ablation-replace: ok restored: blob == HEAD (f8facc4) and `git diff HEAD` is empty ``` </details> ## Acceptance notes - Acceptance 1: a 380 px (and a 360 px) path at a 1280 px viewport draws the compact path; the current stage's name is whole. Acceptance 2: the wide desktop row is pinned pixel-identical to the old switch. Acceptance 3: `ui/e2e/record-path-narrow-drawer-34696.spec.ts`. - A path between 384 px and about 448 px at a desktop viewport still draws the desktop row, as it always did, with stage labels around 48 px (a few letters and an ellipsis). That is the pre-existing look of a narrow full-width page and is unchanged on purpose. - NOT MEASURED: the threshold argument (the narrowest full-width page) is read from the shell's classes, not measured in a running Console; the real drawer was not opened in a running Console either. ## Verification Derived gates (`node scripts/pm/dispatch-gates.mjs --commands`, from the merge base), run on head `68181a75f8`: 38 derived, 38 run, every one `exit 0`. <details><summary>Gate reconciliation</summary> ``` ✓ dispatch-gates --ran: 38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of them is 3). $ pnpm --dir ui exec vitest run --maxWorkers=2 scripts/ Test Files 171 passed | 2 skipped (173) Tests 5077 passed | 2 skipped (5079) $ cd ui && pnpm check:new-line-citations VERDICT new-cross-file-line-citations: 0 new citation(s), enforcement report-only -> exit 0 $ node scripts/pm/overlap-check.mjs --branch=claude/issue-34696-path-container-switch VERDICT clean exit 0 ``` </details> Lint, the type-check lanes, Test UI, Build & E2E UI and the rest of the farm are CI's. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (lint is CI's) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 73f3abb commit 9c70c16

6 files changed

Lines changed: 301 additions & 13 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/plugin-detail': patch
3+
---
4+
5+
fix(ui): the record stage bar uses its compact form in a narrow record drawer, not only on a phone
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`record:path` chose between its desktop row and its compact form by the viewport alone, so a narrow record drawer opened at a desktop viewport drew the desktop row: seven stages in a 380 px drawer got about 33 px each and read as 'P…', 'Pro…', 'Ne…'. The bar now draws the desktop row only when the viewport is at least `sm` and the bar itself is at least 24rem (384 px) wide. Otherwise it draws the compact form: the progress segments, then "Step N of M" and the current stage's full name, which opens the list of every stage.
11+
12+
- Below `sm` nothing changes: the compact form, as before.
13+
- A full-width record page keeps the desktop row, pixel for pixel.
14+
- Nothing is authored for this: no new key, prop or translation string.
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
import { test, expect, type Page } from '@playwright/test';
2+
import { compile } from 'tailwindcss';
3+
import { readFileSync } from 'node:fs';
4+
import { fileURLToPath } from 'node:url';
5+
import path from 'node:path';
6+
import { uiRoot } from '../scripts/ui-root.mjs';
7+
8+
/**
9+
* GEOMETRY pin for `record:path` in a narrow record drawer at a desktop
10+
* viewport (objectstack#34696).
11+
*
12+
* The desktop row and the compact path used to switch on the VIEWPORT alone,
13+
* so a 380 px record drawer at a 1280 px viewport drew the desktop row: seven
14+
* equal shares of about 33 px each, which read as 'P…', 'Pro…', 'Ne…'. The
15+
* path's root is now a Tailwind container and each row stacks `sm` on the
16+
* container's `@sm`, so that drawer draws the compact path, while a wide page
17+
* draws the desktop row exactly as before, and a viewport below `sm` keeps the
18+
* compact path whatever the path's width.
19+
*
20+
* A Playwright spec and not a vitest test for the reason
21+
* `record-header-title-width.spec.ts` gives: jsdom has no layout engine, so a
22+
* width read there is 0 and an assertion on it is vacuous. The class-shape
23+
* half is pinned beside the renderer in `record-path.compact-34595.test.tsx`.
24+
*
25+
* REAL, read out of `record-path.tsx` at run time: the root's class, both
26+
* rows' switch classes, the desktop row's group and stage classes, the label
27+
* and rail base strings and the named PHONE_* constants, plus real Tailwind
28+
* compiled from the installed `tailwindcss` for exactly those candidates.
29+
* FIXTURE: the stage labels, and the element trees, transcribed from the two
30+
* rows.
31+
*/
32+
33+
const REPO_ROOT = uiRoot();
34+
const PATH_FILE = 'packages/plugin-detail/src/renderers/record-path.tsx';
35+
const pathSrc = readFileSync(path.join(REPO_ROOT, PATH_FILE), 'utf8');
36+
37+
/** One string out of the source, asserting tokens so a drifted match throws. */
38+
function grab(re: RegExp, mustContain: string[]): string {
39+
const m = pathSrc.match(re);
40+
if (!m) throw new Error(`${PATH_FILE}: nothing matched ${re}`);
41+
const cls = m[1];
42+
for (const token of mustContain) {
43+
if (!cls.split(/\s+/).includes(token)) {
44+
throw new Error(
45+
`${PATH_FILE}: ${re} matched "${cls}", which does not carry "${token}" — the extraction ` +
46+
'walked onto the wrong string, so this measurement would be meaningless.',
47+
);
48+
}
49+
}
50+
return cls;
51+
}
52+
53+
const CLS = {
54+
root: grab(/<div className=\{cn\('([^']+)', className\)\} \{\.\.\.designer\}>/, ['@container', 'w-full']),
55+
desktop: grab(/\{\/\* Desktop[^\n]*\*\/\}\s*<div\s+className="([^"]+)"/, ['hidden', 'sm:@sm:flex']),
56+
forwardGroup: grab(/<div className="([^"]+)" style=\{shareOf\(forwardStages\.length\)\}>/, ['flex', 'min-w-0']),
57+
lostGroup: grab(/<div\s+className="([^"]+)"\s+style=\{shareOf\(lostStages\.length\)\}/, ['flex', 'border-l']),
58+
stageItem: grab(/className=\{cn\('(flex flex-col gap-1\.5)', listLine/, ['flex-col']),
59+
stageShare: grab(/forwardStages\.map[\s\S]*?className: '([^']+)'/, ['flex-1', 'min-w-0']),
60+
ordinaryLabel: grab(/labelClassName: stageTerminals\[idx\] \? TERMINAL_LABEL_CLASS : '([^']+)'/, ['truncate']),
61+
terminalLabel: grab(/const TERMINAL_LABEL_CLASS = '([^']+)'/, ['[overflow-wrap:anywhere]']),
62+
label: grab(/const labelClass = [\s\S]*?cn\(\s*'([^']+)'/, ['block', 'min-w-0', 'text-xs']),
63+
rail: grab(/const railClass = [\s\S]*?cn\(\s*'([^']+)'/, ['w-full']),
64+
compact: grab(/\{\/\* Mobile:[^\n]*\*\/\}\s*<div\s+className="([^"]+)"/, ['sm:@sm:hidden']),
65+
railRow: grab(/const PHONE_RAIL_ROW_CLASS = '([^']+)'/, ['flex', 'w-full']),
66+
railSegment: grab(/const PHONE_RAIL_SEGMENT_CLASS = '([^']+)'/, ['flex-1', 'min-w-0']),
67+
summary: grab(/const PHONE_SUMMARY_CLASS =\s*'([^']+)'/, ['min-h-11', 'w-full']),
68+
summaryStage: grab(/const PHONE_SUMMARY_STAGE_CLASS = '([^']+)'/, ['[overflow-wrap:anywhere]']),
69+
};
70+
71+
/** The opportunity path the card measured: five open stages, won, then lost. */
72+
const FORWARD = ['Prospecting', 'Qualification', 'Needs Analysis', 'Proposal', 'Negotiation', 'Closed Won'];
73+
const LOST = ['Closed Lost'];
74+
const CURRENT = 'Negotiation';
75+
76+
/** The tree both rows draw, with the switch classes the source gives them (or the old ones). */
77+
const fixture = (cls: { root: string; desktop: string; compact: string }) => {
78+
const stage = (label: string, terminal: boolean) =>
79+
`<div role="listitem" class="${CLS.stageItem} ${CLS.stageShare}">` +
80+
`<span class="${CLS.rail} bg-muted"></span>` +
81+
`<span data-label="${label}" data-ordinary="${terminal ? '' : 'yes'}" class="${CLS.label} font-normal ${
82+
terminal ? CLS.terminalLabel : CLS.ordinaryLabel
83+
}">${label}</span></div>`;
84+
const forward = FORWARD.map((l, i) => stage(l, i === FORWARD.length - 1)).join('');
85+
const lost = LOST.map((l) => stage(l, true)).join('');
86+
const total = FORWARD.length + LOST.length;
87+
return (
88+
`<div id="root" class="${cls.root}">` +
89+
`<div id="desktop" role="list" class="${cls.desktop}">` +
90+
`<div class="${CLS.forwardGroup}" style="flex:${FORWARD.length} 1 0%">${forward}</div>` +
91+
`<div class="${CLS.lostGroup}" style="flex:${LOST.length} 1 0%">${lost}</div>` +
92+
'</div>' +
93+
`<div id="compact" class="${cls.compact}">` +
94+
`<div id="rails" aria-hidden="true" class="${CLS.railRow}">` +
95+
Array.from({ length: total }, (_, i) =>
96+
`<span class="${CLS.rail} bg-muted ${CLS.railSegment}${i === FORWARD.length ? ' ml-1' : ''}"></span>`,
97+
).join('') +
98+
'</div>' +
99+
`<button id="summary" type="button" class="${CLS.summary}">` +
100+
`<span class="shrink-0">Step 5 of ${FORWARD.length}</span><span aria-hidden="true">·</span>` +
101+
`<span id="current" class="${CLS.summaryStage}">${CURRENT}</span>` +
102+
'<svg class="ml-auto h-4 w-4 shrink-0" width="16" height="16"></svg>' +
103+
'</button>' +
104+
'</div>' +
105+
'</div>'
106+
);
107+
};
108+
109+
const NOW = { root: CLS.root, desktop: CLS.desktop, compact: CLS.compact };
110+
/** The switch as it stood before this card: viewport only, no container. */
111+
const BEFORE = {
112+
root: CLS.root.replace('@container', '').trim(),
113+
desktop: CLS.desktop.replace('sm:@sm:flex', 'sm:flex'),
114+
compact: CLS.compact.replace('sm:@sm:hidden', 'sm:hidden'),
115+
};
116+
117+
let css = '';
118+
test.beforeAll(async () => {
119+
const twEntry = fileURLToPath(import.meta.resolve('tailwindcss/index.css'));
120+
const compiler = await compile('@import "tailwindcss";', {
121+
base: path.dirname(twEntry),
122+
loadStylesheet: async (id: string, base: string) => {
123+
const file = id === 'tailwindcss' ? twEntry : path.resolve(base, id);
124+
return { path: file, base: path.dirname(file), content: readFileSync(file, 'utf8') };
125+
},
126+
});
127+
css = compiler.build(
128+
[...Object.values(CLS), ...Object.values(BEFORE), 'bg-muted font-normal ml-1 shrink-0 ml-auto h-4 w-4']
129+
.join(' ')
130+
.split(/\s+/)
131+
.filter(Boolean),
132+
);
133+
if (!css.includes('@container')) {
134+
throw new Error('Tailwind produced no container query — `sm:@sm:flex` would be inert.');
135+
}
136+
});
137+
138+
type Reading = {
139+
desktopShown: boolean;
140+
compactShown: boolean;
141+
labels: { label: string; ordinary: boolean; width: number; clipped: boolean; top: number; left: number }[];
142+
current: { clipped: boolean; right: number };
143+
railsFit: boolean;
144+
drawerRight: number;
145+
};
146+
147+
async function readPath(
148+
page: Page,
149+
opts: { viewport: number; container: number; cls?: typeof NOW; forceDesktop?: boolean },
150+
): Promise<Reading> {
151+
await page.setViewportSize({ width: opts.viewport, height: 900 });
152+
const force = opts.forceDesktop ? '#desktop{display:flex!important}' : '';
153+
await page.setContent(
154+
`<style>html,body{margin:0}body{font:14px sans-serif}${css}${force}</style>` +
155+
`<div id="drawer" style="width:${opts.container}px">${fixture(opts.cls ?? NOW)}</div>`,
156+
{ waitUntil: 'load' },
157+
);
158+
await page.evaluate(() => document.fonts?.ready);
159+
return page.evaluate(() => {
160+
const round = (n: number) => Math.round(n * 100) / 100;
161+
const shown = (id: string) => getComputedStyle(document.getElementById(id)!).display !== 'none';
162+
const cur = document.getElementById('current')!;
163+
const rails = document.getElementById('rails')!;
164+
return {
165+
desktopShown: shown('desktop'),
166+
compactShown: shown('compact'),
167+
labels: Array.from(document.querySelectorAll<HTMLElement>('#desktop [data-label]')).map((el) => {
168+
const r = el.getBoundingClientRect();
169+
return {
170+
label: el.dataset.label!,
171+
ordinary: el.dataset.ordinary === 'yes',
172+
width: round(r.width),
173+
clipped: el.scrollWidth > el.clientWidth,
174+
top: round(r.top),
175+
left: round(r.left),
176+
};
177+
}),
178+
current: { clipped: cur.scrollWidth > cur.clientWidth, right: round(cur.getBoundingClientRect().right) },
179+
railsFit: rails.scrollWidth <= rails.clientWidth,
180+
drawerRight: round(document.getElementById('drawer')!.getBoundingClientRect().right),
181+
};
182+
});
183+
}
184+
185+
test.describe('record:path in a narrow drawer at a desktop viewport (objectstack#34696)', () => {
186+
test('the defect this pins: at 380px the desktop row gives each stage under 50px and cuts the long names', async ({ page }) => {
187+
// Forced on, the desktop row shows what the drawer drew before: not vacuous.
188+
const r = await readPath(page, { viewport: 1280, container: 380, forceDesktop: true });
189+
const ordinary = r.labels.filter((l) => l.ordinary);
190+
expect(ordinary).toHaveLength(FORWARD.length - 1);
191+
for (const l of ordinary) expect(l.width, `${l.label} got ${l.width}px`).toBeLessThan(50);
192+
for (const name of ['Prospecting', 'Qualification', 'Needs Analysis', 'Negotiation']) {
193+
expect(ordinary.find((l) => l.label === name)?.clipped, `${name} fit whole in the desktop row at 380px`).toBe(true);
194+
}
195+
});
196+
197+
for (const container of [360, 380]) {
198+
test(`a ${container}px drawer at a 1280px viewport draws the compact path, the current stage whole`, async ({ page }) => {
199+
const r = await readPath(page, { viewport: 1280, container });
200+
expect(r.desktopShown, 'the desktop row still draws in the narrow drawer').toBe(false);
201+
expect(r.compactShown, 'the compact path is hidden in the narrow drawer').toBe(true);
202+
expect(r.current.clipped, `${CURRENT} is cut`).toBe(false);
203+
expect(r.current.right).toBeLessThanOrEqual(r.drawerRight + 0.5);
204+
expect(r.railsFit, 'the rail spills out of its row').toBe(true);
205+
});
206+
}
207+
208+
test('a viewport below `sm` keeps the compact path even in a path wider than `@sm`', async ({ page }) => {
209+
const r = await readPath(page, { viewport: 600, container: 560 });
210+
expect(r.desktopShown).toBe(false);
211+
expect(r.compactShown).toBe(true);
212+
});
213+
214+
test('CONTROL — a 900px path at a 1280px viewport draws the desktop row, every label readable', async ({ page }) => {
215+
const r = await readPath(page, { viewport: 1280, container: 900 });
216+
expect(r.desktopShown, 'the wide page lost its desktop row').toBe(true);
217+
expect(r.compactShown, 'the wide page drew the compact path').toBe(false);
218+
for (const l of r.labels) {
219+
expect(l.clipped, `${l.label} is cut on the wide page`).toBe(false);
220+
expect(l.width).toBeGreaterThan(80);
221+
}
222+
});
223+
224+
test('CONTROL — the wide desktop row is pixel-identical to the viewport-only switch it replaces', async ({ page }) => {
225+
for (const container of [900, 1200]) {
226+
const now = await readPath(page, { viewport: 1280, container, cls: NOW });
227+
const before = await readPath(page, { viewport: 1280, container, cls: BEFORE });
228+
expect(before.desktopShown).toBe(true);
229+
expect(now.labels, `the desktop row moved at ${container}px`).toEqual(before.labels);
230+
}
231+
});
232+
});

‎ui/e2e/record-path-phone-row.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function grab(re: RegExp, mustContain: string[]): string {
5050
}
5151

5252
const CLS = {
53-
compact: grab(/\{\/\* Mobile:[^\n]*\*\/\}\s*<div\s+className="([^"]+)"/, ['sm:hidden']),
53+
compact: grab(/\{\/\* Mobile:[^\n]*\*\/\}\s*<div\s+className="([^"]+)"/, ['sm:@sm:hidden']),
5454
rail: grab(/const railClass = [\s\S]*?cn\(\s*'([^']+)'/, ['w-full']),
5555
railRow: grab(/const PHONE_RAIL_ROW_CLASS = '([^']+)'/, ['flex', 'w-full']),
5656
railSegment: grab(/const PHONE_RAIL_SEGMENT_CLASS = '([^']+)'/, ['flex-1', 'min-w-0']),
@@ -92,7 +92,7 @@ test.beforeAll(async () => {
9292
[...Object.values(CLS), 'bg-muted ml-1 shrink-0 ml-auto h-4 w-4'].join(' ').split(/\s+/).filter(Boolean),
9393
);
9494
if (!css.includes('@media')) {
95-
throw new Error('Tailwind produced no media queries — `sm:hidden` would be inert.');
95+
throw new Error('Tailwind produced no media queries — `sm:@sm:hidden` would be inert.');
9696
}
9797
});
9898

‎ui/packages/plugin-detail/src/renderers/__tests__/record-path.compact-34595.test.tsx‎

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ const tokens = (el: Element): string[] => el.className.split(/\s+/).filter(Boole
6767
const textOf = (el: Element): string => (el.textContent ?? '').replace(/[✓✗]/g, '').trim();
6868

6969
describe('record:path below `sm` is the compact path (objectstack#34595)', () => {
70-
it('is drawn only below `sm`, beside the desktop rail', () => {
70+
it('is drawn below `sm` (and in a path narrower than `@sm`, objectstack#34696), beside the desktop rail', () => {
7171
const r = mount('negotiation');
72-
expect(tokens(compactOf(r))).toContain('sm:hidden');
72+
expect(tokens(compactOf(r))).toContain('sm:@sm:hidden');
7373
const desktop = r.container.querySelector('[role="list"]') as HTMLElement;
74-
expect(tokens(desktop)).toEqual(expect.arrayContaining(['hidden', 'sm:flex']));
74+
expect(tokens(desktop)).toEqual(expect.arrayContaining(['hidden', 'sm:@sm:flex']));
7575
expect(compactOf(r).contains(desktop)).toBe(false);
7676
});
7777

@@ -154,3 +154,31 @@ describe('record:path below `sm` is the compact path (objectstack#34595)', () =>
154154
expect(within(desktop).queryByRole('button')).toBeNull();
155155
});
156156
});
157+
158+
describe('record:path picks its row by the viewport AND its own width (objectstack#34696)', () => {
159+
// A 380 px record drawer at a desktop viewport drew the desktop row, whose
160+
// seven equal shares cut each stage to a letter. The path's root is now a
161+
// container, and each row's switch stacks `sm` on the container's `@sm`.
162+
it('the root is the container both rows query, with no container between', () => {
163+
const r = mount('negotiation');
164+
const compact = compactOf(r);
165+
const desktop = r.container.querySelector('[role="list"]') as HTMLElement;
166+
const root = compact.parentElement as HTMLElement;
167+
expect(desktop.parentElement).toBe(root);
168+
expect(tokens(root)).toEqual(expect.arrayContaining(['@container', 'w-full']));
169+
for (const row of [compact, desktop]) {
170+
expect(row.closest('[class~="@container"]')).toBe(root);
171+
}
172+
});
173+
174+
it('neither row switches on the viewport alone any more', () => {
175+
const r = mount('negotiation');
176+
const compact = tokens(compactOf(r));
177+
const desktop = tokens(r.container.querySelector('[role="list"]') as HTMLElement);
178+
expect(compact).toContain('sm:@sm:hidden');
179+
expect(compact).not.toContain('sm:hidden');
180+
expect(compact).not.toContain('hidden');
181+
expect(desktop).toEqual(expect.arrayContaining(['hidden', 'sm:@sm:flex']));
182+
expect(desktop).not.toContain('sm:flex');
183+
});
184+
});

‎ui/packages/plugin-detail/src/renderers/__tests__/record-path.phoneRow-26897.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('record:path — the phone row fits and ellipsises (objectstack#26897)'
7474
const r = mount();
7575
const phone = rows(r)[1];
7676
const compact = phone.closest('[data-record-path-compact]') as HTMLElement;
77-
expect(tokens(compact)).toContain('sm:hidden');
77+
expect(tokens(compact)).toContain('sm:@sm:hidden'); // objectstack#34696: viewport AND path width
7878
const rails = Array.from(compact.querySelectorAll('[data-record-path-rails] > [data-stage-rail]')) as HTMLElement[];
7979
expect(rails).toHaveLength(CASE_STAGES.length);
8080
for (const rail of rails) {
@@ -114,7 +114,7 @@ describe('record:path — the phone row fits and ellipsises (objectstack#26897)'
114114

115115
it('CONTROL: the desktop rail is unchanged — no title, the ordinary label still truncates', () => {
116116
const desktop = rows(mount())[0];
117-
expect(tokens(desktop)).toContain('sm:flex');
117+
expect(tokens(desktop)).toContain('sm:@sm:flex'); // objectstack#34696: viewport AND path width
118118
const el = labelOf(stageNamed(desktop, 'Waiting on Customer'));
119119
expect(tokens(el)).toContain('truncate');
120120
expect(el).not.toHaveAttribute('title');

0 commit comments

Comments
 (0)