Repository navigation
Commit 6a7403b
fix(print): a zh-CN record page prints dates in Chinese order, fits its line items to the sheet, and prints on white with plain values (#34422)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XRT27U1unc64yMdYqqPWFjw)_
Part of #34228
Ruling-ref: 6922479414 (item 3 of #34228: the maintainer chose C
「规则不动,拆开报价单模板」; `avoidBreakInside` keeps its published meaning, the
quote template is split instead)
Clause-②: no
Metadata-protocol: none
This PR builds items 1, 2 and 4 of the card. Item 3 (the blank half page
under `avoidBreakInside`) was measured (below) and ruled C by the
maintainer (record 6922479414): `avoidBreakInside` keeps its published
meaning, and a print page that may break between sections authors one
`record:details` block per section. Where the rest of that ruling goes:
the reply to the reporter is on #34228; the HotCRM quote template split
is hotcrm#2553; the one-sentence guidance in
`content/docs/ui/print-pages.mdx` and
`skills/objectstack-ui/rules/pages.md` is the separate text PR #34436
(`Part of #34228`, Tier H, handed to the maintainer by the seat); a long
`record:line_items` table moving whole to the next sheet is #34427,
outside this ruling.
## 维护者速读
- 改了什么:中文组织打印记录页时,`format: 'short'`
的日期按语言自己的顺序显示(`2026年11月15日`);打印时明细表收进纸宽;纸面为白底,查找字段和下拉选项印成普通文字。
- 为什么改:报价单这类发给客户的文件在中文环境下日期印成 `11月 15, '26`,五列明细表超出卡片边框,背景发灰,状态印成彩色胶囊。
- 风险与回滚:日期改动在屏幕上同样生效,凡是非“月-日-年”语言(中、日、韩、德、英式英语)的 `short`
日期都会变成该语言自己的写法,英语(美式)不变;打印规则只在 `@media print` 且限定在打印页内。回滚即还原本 PR。
- 先看:`ui/packages/core/src/utils/date-display.ts`(`short`
分支的语言顺序判断)、`ui/packages/components/src/renderers/layout/page-print.ts`(新增的三组打印规则)、`ui/packages/fields/src/index.tsx`(下拉徽章上的打印钩子属性)。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/core/src/utils/__tests__/date-display.shortLocaleOrder-34228.test.ts`,预期全部通过,`zh-CN`
一行断言 `2026年11月15日`。
- 需要你做的:无。第 3 项已裁 C(记录 6922479414):规则不动,由模板拆块解决;答复报告人在 #34228,HotCRM
模板拆块是 hotcrm#2553,docs/skills 各补一句由文字 PR #34436 承接,明细表整表移页另立 #34427。本 PR
由席位落地。
## What changes
**Item 1, dates.** The mechanism the dispatch named was measured first
and does not hold. Headless Chromium does run with `en-US` as its
default (`navigator.language` = `en-US`, Chromium 153.0.8010.12), but
every date renderer passes an explicit tag (`useDisplayLocale()` never
answers `undefined`), and in that same Chromium
`toLocaleDateString('zh-CN', { month: 'short' })` answers `11月`. The
record page and the list grid draw a date through the same
`DateCellRenderer`. The shape `11月 15, '26` has one producer in the
tree: `formatDate`'s `'short'` face. That face put a localized month
token into a fixed English layout (`Nov 15, '26`). The quote's date
fields are authored `format: 'short'` (the HotCRM quote object declares
it on `quote_date` and `expiration_date` so that they always show the
year). So the same face showed on screen and on paper.
The fix is at that producer. The compact layout is kept only where it is
the locale's own order (month → day → year, asked of
`Intl.DateTimeFormat#formatToParts`, cached per tag). Every other locale
gets its own date with the year, which is the default face with the year
shown: `zh-CN` / `ja-JP` `2026年11月15日`, `ko-KR` `2026년 11월 15일`, `de-DE`
`15. Nov. 2026`, `en-GB` `15 Nov 2026`. `en` / `en-US` stay `Nov 15,
'26`, byte for byte. The change reaches every reader of `formatDate(v,
'short', { locale })` (date cells, dataset measures), on screen and on
paper alike. There is no print-only formatter.
**Item 2, tables fit the sheet.** On a print page, every data table
except the running header/footer table gets `width: 100%`, and its cells
drop the on-screen `min-width` and `white-space: nowrap` (`!important`,
because the grid sets the minimum width inline). The columns then shrink
and wrap to the box. The overflow was what drew the stray vertical rule:
the wrapper's right border ran through the last column.
**Item 4, document face.** On paper the page and its ancestors print on
`#fff`. Links print in the surrounding colour with no underline; a
lookup's reference is a link. A select value's badge prints as its
label: no fill, transparent border, no padding, no radius, with
`!important` so that it also beats a hex option colour's inline style.
To give the stylesheet a stable hook, `SelectCellRenderer`'s badge
carries a new inert `data-select-badge` attribute. Nothing reads it on
screen. Every new rule sits inside `@media print` and names
`[data-print-page]`, and a test pins that for every rule of the sheet.
The optional page-level switch from the card is not built (it would add
a spec key).
## Tests
-
`ui/packages/core/src/utils/__tests__/date-display.shortLocaleOrder-34228.test.ts`:
six non-month-first locales get their own face; `en` / `en-US` controls
keep `Nov 15, '26`; the `short` face equals the default face with
`alwaysShowYear`.
-
`ui/packages/plugin-detail/src/__tests__/recordDetailsPrintFace-34228.test.tsx`:
a real `record:details` on a real print page (`SchemaRenderer` →
`PageRenderer`) under `LocalizationProvider` `zh-CN` draws `2026年11月15日`
(control: `en` draws `Nov 15, '26`). A rule of the stylesheet the page
actually mounts matches the real select badge and the real lookup
anchor, with the plain-text declarations.
-
`ui/packages/components/src/__tests__/page-print-paper-34228.test.tsx`:
the rule text; every rule is scoped to the print page; the fit selectors
match a data table and its cells on a real print page and never the
running-region table or its cells.
- Re-judged pins: `date-formatter-residue-4272.test.ts` pinned `8月 15,
'26` / `Okt 15, '26`, the face this card retires. Its expected values
are now `2026年8月15日` / `15. Okt. 2026`, and the `en` must-not-change
pins are untouched. One assertion in
`page-print-stylesheet-11958.test.tsx` was a substring
(`data-print-running]) {`) that the new fit rule also contains. It now
spells the running-region rule it meant (`:has(>
table[data-print-running]) {`).
<details><summary>Suite readings</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/core/
packages/fields/ packages/components/ packages/plugin-detail/
packages/plugin-form/` on `dd8fec17`: `Test Files 1639 passed | 3
skipped (1642)`, `Tests 19666 passed | 77 skipped (19743)`, lock
`VERDICT command-exit 0`.
- The commit after `dd8fec17` (`23cdb744`) changes two test files only:
a module-top `import '@object-ui/react-runtime'` that
`check:test-source-alias` asked for. Their local rerun and `type-check`
of `@object-ui/core`, `fields`, `components` and `plugin-detail`: NOT
MEASURED, reason: four tries at the shared verify lock found no free
turn (exit 99) behind a dogfood build and test run. CI's `Type Check UI`
and `Test UI` carry both.
- Derived gate subset at `23cdb744`: 37 of 39 families ran locally and
exited 0 (`check:test-source-alias` after the fix above). `pnpm
check:type-check-debt`: NOT MEASURED (exit 3; its closure build got no
lock turn). `pnpm --dir ui exec vitest run scripts/`: not run, CI-owned.
</details>
## Acceptance notes
- **Item 3, measured and reported (not built).** Harness: the real DOM
of a print page (`record:details` of one section, a 5-column
`record:line_items`, then a `record:details` of two sections, `pricing`
and `terms`, 11 short fields) rendered through `SchemaRenderer`, the
console's compiled Tailwind sheet, Chromium 153 `page.pdf`, A4 portrait
with 18/15 mm margins, `avoidBreakInside: true`, and the blank space
read from `pdftotext -bbox`.
- Does the block fit one sheet? Yes. The two-section block is about 472
pt tall on a 740 pt printable sheet (64%). So `break-inside: avoid`
keeps a block that fits whole on one sheet. That is exactly what the
published text says: "keep each block whole on one sheet when it fits".
- With 3 lines, page 1 is 35% blank with the key on and 4% blank with it
off. With 6 lines it is 18% on and 0% off. With the key off, the 6-line
page splits inside the `pricing` section, which is the split the key
exists to prevent.
- A per-section rule (`break-inside: avoid` on each section card of
`record:details`, the block-level rule left on every other block),
injected into the same page: 3 lines leaves 4% blank on page 1, with
`pricing` whole on page 1 and `terms` whole on page 2. 6 lines gives
18%, the same as today, because `pricing` does not fit the space left
either.
- For other print pages, a per-section rule lets one `record:details`
block run across two sheets between sections. The showcase invoice's
`invoice` and `amounts` sections could then print on different sheets.
Every block that is not `record:details` would be unchanged.
- A per-section rule would change what `avoidBreakInside` declares ("on
every block"). The maintainer ruled C (record 6922479414): the rule
stays, and the quote template is split into one `record:details` per
section instead. Measured on the split template: page 1 is 4% blank with
3 lines and 18% with 6 (dev report 6923091449 on #34228).
- The `short` face change shows on screen too: a `zh-CN` user's record
page and list cells for a `format: 'short'` date now read `2026年11月15日`.
This is the same defect, fixed at its producer.
- **Seat condition (b), red first on the screen face.** Ablation, run
once (not a test file): with
`ui/packages/core/src/utils/date-display.ts` swapped back to its
`cfcba539` version on head `98f29438`,
`date-display.shortLocaleOrder-34228` and `recordDetailsPrintFace-34228`
fail 8 of 13. `zh-CN`, `zh` and `ja-JP` expect `2026年11月15日` and receive
`11月 15, '26`; `ko-KR`, `de-DE` and `en-GB` fail too; the `zh-CN` print
page renders `Quote Date 11月 15, '26`. The `en` and `en-US` controls
stay green. With the file restored from HEAD (blob `e9d02cc1` matches,
`git diff HEAD` is empty) both files pass 13/13. Dev report 6925134613
on #34228.
- **Dark theme does not regress.** The console already prints dark-theme
text black: the app-shell print rule
(`ui/packages/app-shell/src/styles.css`, `.dark, .dark *` get `color:
#000 !important` inside `@media print`) does this, not the page print
stylesheet. Measured on a body field value, A4, headless Chromium with
`class="dark"` on the root: with background graphics on, `cfcba539`
printed black text on the dark (18,18,18) canvas, which cannot be read,
and `98f29438` prints it on white; with background graphics off, both
builds print black on white. Still present in both builds and not
changed here: with background graphics on, the `@page` margin band
prints dark (18,18,18) in dark theme (measured in a scratch harness
only); filed as #34446.
- Column headings wrap where they must: `Discount %` prints as two lines
in the 5-column table.
## Verification
Chromium 153.0.8010.12 (`/opt/pw-browsers/chromium`), the real
print-page DOM of the item-3 harness (`zh-CN`, 6 lines, prices
`¥1,234,567.89`, totals `¥12,345,678.90`), the console's compiled
stylesheet, inside a grey app shell. Geometry is read under
`emulateMedia('print')` at the A4 printable width (680 px, transitions
off); the PDF is read with `pdftoppm` and `pdftotext`.
<details><summary>Before (main cfcba53) / after</summary>
| reading | before | after |
|:---|:---|:---|
| `record:line_items` table vs its 630 px box | 647 px, overflows by
17.6 px; the box's right border runs through `Total` | 628 px, inside
the box |
| column widths (#, Product, Quantity, Sales Price, Discount %, Total) |
25 / 160 / 104 / 122 / 104 / 131 | 40 / 184 / 71 / 122 / 79 / 131 |
| body / page background | `rgb(237, 237, 242)` / `rgb(246, 246, 249)` |
`rgb(255, 255, 255)` / `rgb(255, 255, 255)` |
| lookup `北京黑猫科技有限公司` | `rgb(0, 123, 255)` | `rgb(2, 8, 23)` = the
page's text colour |
| select `已批准` badge | green fill, 1px green border, full radius, 10px
padding | transparent fill and border, radius 0, padding 0, text `rgb(2,
8, 23)` |
| dates in the PDF | `11月 15, '26`, `12月 15, '26` | `2026年11月15日`,
`2026年12月15日` |
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5pNoRjsgMJKr5utN33)_
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5pNoRjsgMJKr5utN33 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 54f8e16 commit 6a7403b
9 files changed
Lines changed: 454 additions & 12 deletions
File tree
- .changeset
- ui/packages
- components/src
- __tests__
- renderers/layout
- core/src/utils
- __tests__
- fields/src
- __tests__
- plugin-detail/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
64 | 73 | | |
65 | 74 | | |
66 | 75 | | |
| |||
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
114 | 159 | | |
115 | 160 | | |
116 | 161 | | |
| |||
135 | 180 | | |
136 | 181 | | |
137 | 182 | | |
| 183 | + | |
138 | 184 | | |
139 | 185 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
157 | 187 | | |
158 | 188 | | |
159 | 189 | | |
| |||
595 | 625 | | |
596 | 626 | | |
597 | 627 | | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
604 | 644 | | |
605 | 645 | | |
606 | 646 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | | - | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
| 72 | + | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| |||
0 commit comments