Repository navigation
Commit 24366ff
fix(fields): a markdown heading in a list cell draws at the cell's text size (objectstack-ai#36428)
Fixes objectstack-ai#36344
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户在列表里看到的变化:含 Markdown
字段的列表单元格,内容以标题开头时不再以大标题字号显示、也不再把这一行撑高,行高与其他行一致;记录详情页仍按原样显示大标题。
- 为什么做:列表视图体验修复,替在列表中显示富文本列的用户解决「标题被截断、行变高」的问题。
- 出错会怎样:最坏情况是列表里 Markdown 单元格的样式不对(只影响显示,不影响数据),可以直接撤回本次改动。
- 要你做什么:无。
## What changes
- `@object-ui/fields` `MarkdownContent` gains a `face` prop: `document`
(the default, unchanged) and `cell`. The cell face draws every heading
level as a `p.font-semibold` (no heading element) and the body takes the
surrounding cell's font size and line height (`text-[length:inherit]
leading-[inherit]` on top of the same `prose prose-sm` typography).
- `MarkdownCellRenderer` picks the cell face when `inGridColumn` is set.
`ObjectGrid` already passes `inGridColumn` on every column cell, and
`RelatedList` on every table cell, so no host changes. The record page,
readonly form fields and every other caller pass nothing and keep the
`document` face with its heading sizes.
- `CellRendererProps.inGridColumn` JSDoc now names the `markdown` cell
as its second reader.
- Changeset: `@object-ui/fields` patch.
Read first (by risk):
1. `ui/packages/fields/src/widgets/MarkdownContent.tsx` — the cell face:
`CELL_COMPONENTS` (heading levels mapped to a paragraph) and
`MARKDOWN_CELL_FACE_CLASS`. Sanitisation is unchanged: the same
`rehype-sanitize` schema runs in both faces; the component map only
renames the element of a node the sanitiser already passed.
2. `ui/packages/fields/src/widgets/richTextDisplay.tsx` — the one line
that chooses the face from `inGridColumn`.
3. `ui/packages/fields/src/__tests__/markdownCellHeading-36344.test.tsx`
— the pins and the record-page control.
Two-minute check: `pnpm --dir ui exec vitest run
packages/fields/src/__tests__/markdownCellHeading-36344.test.tsx
packages/plugin-grid/src/__tests__/ObjectGrid.richTextOneLine-12480.test.tsx`
from the repository root — expect 2 files, 8 tests passed.
## Tests
- New
`ui/packages/fields/src/__tests__/markdownCellHeading-36344.test.tsx` (3
cases): in a grid column, a `# Heading` value draws no `h1`-`h6`, the
heading is a `p.font-semibold`, the body carries the two inherit classes
and stays formatted; all six heading levels are drawn the same way;
CONTROL — without `inGridColumn` (the record page path) the `h1` stays
and the inherit classes are absent.
- New top-level `describe` in
`ui/packages/plugin-grid/src/__tests__/ObjectGrid.richTextOneLine-12480.test.tsx`
(the existing one-line-clamp harness): through the real `ObjectGrid`,
the markdown cell inside the clamp is the cell face and `tbody` holds no
heading element. This is the row-height contract the grid relies on (one
line inside `line-clamp-1`, at the cell's line height).
- The existing readonly form pin
(`readonly-richtext-display-5498.test.tsx`, a readonly markdown field
keeps its `h1`) stays green: full-size displays keep their heading
elements.
<details><summary>Ablation (one, the behaviour the pins hold)</summary>
The fix committed first; mutation through `scripts/ablation-replace.mjs`
on `richTextDisplay.tsx`, anchor `face={inGridColumn ? 'cell' :
'document'}` replaced by `face={'document'}` (anchor x1 to x0, blob
c327713 to a365cf70). No build step: vitest resolves
`@object-ui/fields` to `src` through `ui/vitest.config.mts`'s alias.
- Mutated: `Test Files 2 failed | 1 passed (3)`, `Tests 3 failed | 5
passed (8)`. The three cell-face cases went red (`AssertionError:
expected` an empty `h1` element `to be null`), the record-page control
and the original objectui#12480 cases stayed green.
- Restored: blob after restore c327713 == blob at HEAD, `git diff HEAD`
empty.
</details>
<details><summary>Pixel reading (Chromium, not the live app)</summary>
Harness: the DOM of a real `ObjectGrid` render (jsdom, 4 rows: plain
text, `# Heading` + paragraph, `**bold** and _em_`, `## Second level`)
and of the record-page `MarkdownCellRenderer`, laid into a page with the
Console's own stylesheet compiled from `ui/apps/console/src/index.css`
(Tailwind 4 + typography), opened in Chromium at 1280 px. A temporary
dump test, not committed.
| row | before (ablated) | after |
|---|---|---|
| plain text | 36 px | 36 px |
| `# Heading` + paragraph | 45 px (H1 30px / 36px line) | 36 px (P 14px
/ 17.5px line) |
| `**bold** and _em_` | 36 px | 36 px |
| `## Second level` | 36.5 px (H2 20px / 28px line) | 36 px |
| record page `h1` | 30 px | 30 px |
The 36 to 45 px reading matches the card's. NOT MEASURED in the running
Console against a backend (the harness uses the real component DOM and
the real stylesheet, but no live list page).
</details>
## Acceptance notes
- Scope edge: `wrap: true` columns also pass `inGridColumn`, so a
wrapped markdown cell draws headings as bold lines at the cell size too.
The block structure (paragraphs, lists) is kept, so a wrapped cell still
shows the whole document, just without heading sizes. A list cell is not
a full-size display, so this reads as within the card.
- Observation, not filed: the `html` / `richtext` cell
(`HtmlCellRenderer`, a different pipeline, `renderSanitizedHtml`) keeps
its heading elements in a grid cell under the same `prose prose-sm`, so
a stored `h1` tag should draw the same way. Read from the code only; not
measured at a public entry point, so it is noted here, not filed.
- Out of scope per the card: in-cell editing of rich-text fields
(objectstack-ai#36023, PR objectstack-ai#36278). `overlap-check` before push: no open PR head shares
a file with this branch, and the branch merges cleanly with
`origin/main`.
## Verification
All readings on head `e241a872` (branch merged with `origin/main` at
97b9d1e before the runs), each under `scripts/pm/os-verify-lock.sh`,
unless noted.
<details><summary>Tests</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2` over the six rich-text
files (the two new pins, `readonly-richtext-display-5498`,
`richtext-cell-renderer-5452`, `cellRenderers.childlessContainer-8580`,
`RelatedList.longFormColumns`): `Test Files 6 passed (6)`, `Tests 55
passed (55)`.
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/fields/`: `Test
Files 322 passed | 1 skipped (323)`, `Tests 4846 passed | 7 skipped
(4853)`.
- `pnpm --filter @object-ui/fields run type-check` exit 0; `pnpm
--filter @object-ui/plugin-grid run type-check` exit 0 (both run `tsc
--noEmit && tsc -p tsconfig.test.json`, after building the
`@object-ui/plugin-grid` dependency closure).
- The ablation above ran on `919a2f4f`, the commit before the
`origin/main` merge; the merge brought no change to the files it reads.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` (no paths): 39
families for the 6 changed paths. All 39 run, each exit 0, including
`pnpm --dir ui exec vitest run scripts/` (`Test Files 172 passed | 2
skipped (174)`). `pnpm check:type-check-debt` answered exit 3
(PREREQUISITE NOT MET, no built closure) in the first sweep and exit 0
on the re-run (`check-type-check-coverage --re-measure: OK`).
- `--ran` reconciliation: `39 derived famil(ies) accounted for — 39 run,
0 NOT-MEASURED (a DERIVED zero — all 39 recorded an exit code and none
of them is 3)`.
- `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0`
(origin/main merges cleanly; 0 open PR heads share a file).
- Repo-wide families (lint, the full UI test shards, dogfood) are CI's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent d8628ac commit 24366ff
6 files changed
Lines changed: 192 additions & 7 deletions
File tree
- .changeset
- ui/packages
- fields/src
- __tests__
- widgets
- plugin-grid/src/__tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
444 | 451 | | |
445 | 452 | | |
446 | 453 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 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 | + | |
7 | 43 | | |
8 | 44 | | |
9 | 45 | | |
10 | 46 | | |
11 | 47 | | |
12 | 48 | | |
13 | | - | |
| 49 | + | |
| 50 | + | |
14 | 51 | | |
15 | | - | |
16 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
17 | 58 | | |
18 | 59 | | |
19 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | | - | |
| 100 | + | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
98 | 104 | | |
99 | | - | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 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 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
0 commit comments