diff --git a/.changeset/34696-path-narrow-drawer.md b/.changeset/34696-path-narrow-drawer.md new file mode 100644 index 00000000000..92c2d2f25a5 --- /dev/null +++ b/.changeset/34696-path-narrow-drawer.md @@ -0,0 +1,14 @@ +--- +'@object-ui/plugin-detail': patch +--- + +fix(ui): the record stage bar uses its compact form in a narrow record drawer, not only on a phone + +Clause-②: no +Metadata-protocol: none + +`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. + +- Below `sm` nothing changes: the compact form, as before. +- A full-width record page keeps the desktop row, pixel for pixel. +- Nothing is authored for this: no new key, prop or translation string. diff --git a/ui/e2e/record-path-narrow-drawer-34696.spec.ts b/ui/e2e/record-path-narrow-drawer-34696.spec.ts new file mode 100644 index 00000000000..41bb09bb946 --- /dev/null +++ b/ui/e2e/record-path-narrow-drawer-34696.spec.ts @@ -0,0 +1,232 @@ +import { test, expect, type Page } from '@playwright/test'; +import { compile } from 'tailwindcss'; +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; +import { uiRoot } from '../scripts/ui-root.mjs'; + +/** + * GEOMETRY pin for `record:path` in a narrow record drawer at a desktop + * viewport (objectstack#34696). + * + * The desktop row and the compact path used to switch on the VIEWPORT alone, + * so a 380 px record drawer at a 1280 px viewport drew the desktop row: seven + * equal shares of about 33 px each, which read as 'P…', 'Pro…', 'Ne…'. The + * path's root is now a Tailwind container and each row stacks `sm` on the + * container's `@sm`, so that drawer draws the compact path, while a wide page + * draws the desktop row exactly as before, and a viewport below `sm` keeps the + * compact path whatever the path's width. + * + * A Playwright spec and not a vitest test for the reason + * `record-header-title-width.spec.ts` gives: jsdom has no layout engine, so a + * width read there is 0 and an assertion on it is vacuous. The class-shape + * half is pinned beside the renderer in `record-path.compact-34595.test.tsx`. + * + * REAL, read out of `record-path.tsx` at run time: the root's class, both + * rows' switch classes, the desktop row's group and stage classes, the label + * and rail base strings and the named PHONE_* constants, plus real Tailwind + * compiled from the installed `tailwindcss` for exactly those candidates. + * FIXTURE: the stage labels, and the element trees, transcribed from the two + * rows. + */ + +const REPO_ROOT = uiRoot(); +const PATH_FILE = 'packages/plugin-detail/src/renderers/record-path.tsx'; +const pathSrc = readFileSync(path.join(REPO_ROOT, PATH_FILE), 'utf8'); + +/** One string out of the source, asserting tokens so a drifted match throws. */ +function grab(re: RegExp, mustContain: string[]): string { + const m = pathSrc.match(re); + if (!m) throw new Error(`${PATH_FILE}: nothing matched ${re}`); + const cls = m[1]; + for (const token of mustContain) { + if (!cls.split(/\s+/).includes(token)) { + throw new Error( + `${PATH_FILE}: ${re} matched "${cls}", which does not carry "${token}" — the extraction ` + + 'walked onto the wrong string, so this measurement would be meaningless.', + ); + } + } + return cls; +} + +const CLS = { + root: grab(/