Repository navigation
Commit 06c3e5a
fix(fields): an html or richtext cell holding a heading keeps the list row one line high (#36566)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9GPJ8pmbK219Pay95x25Uno)_
Fixes #36452
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 列表里富文本或 HTML
字段的值以标题开头时,这一行原来会被撑高,现在和其他行一样高、标题按单元格字号加粗显示;记录详情页和只读表单里的标题仍是原来的大字号。
- 这是上一张卡(列表里 Markdown 标题按单元格字号显示)的同类补齐,替所有在列表里看富文本字段的用户解决行高不齐。
- 出错的话,最坏是列表单元格里的标题显示成普通加粗文字或仍偏大,不影响数据和内容过滤安全,可直接撤回此改动。
- 无
## What changes
- `HtmlCellRenderer` (the `html` and `richtext` display pipeline) now
reads `inGridColumn`. In a grid column it draws the sanitized tree in
the same `cell` face the markdown cell got: every heading level is a
`p.font-semibold` at the cell's own text size, and the body takes the
cell's font size and line height. Outside a grid column (record page,
readonly form field) nothing changes: heading elements and `prose-sm`
sizes stay.
- One definition for both pipelines: the face classes and the heading
element map move from `MarkdownContent.tsx` into `richTextDisplay.tsx`
(`RICH_TEXT_DOCUMENT_CLASS`, `RICH_TEXT_CELL_FACE_CLASS`,
`cellFaceHeadings(marker)`), and `MarkdownContent` imports them. They
live in `richTextDisplay` rather than in `MarkdownContent` so the html
cell does not pull the lazy react-markdown chunk into the eager bundle.
None of these is exported from the package barrel.
- `renderSanitizedHtml(html, components?)` takes an optional element map
handed to `toJsxRuntime`. It is applied after `rehype-sanitize` has run,
so it changes how a kept element is drawn, never what is kept: the
allow-list and the strip list are untouched.
- The html container now carries `data-html-face="cell|document"` (the
markdown one already carried `data-markdown-face`); its `innerHTML` is
unchanged in the document face, which the 8580 byte-for-byte pin
confirms.
## Tests
- `ui/packages/fields/src/__tests__/markdownCellHeading-36344.test.tsx`
(the cell-heading face harness, new top-level describe): html and
richtext in a grid column draw no heading element, the heading is
`P.font-semibold` with `data-html-heading`, the face carries
`text-[length:inherit] leading-[inherit]`, the script in the value is
still stripped; all six levels map; the html and markdown cells produce
the same heading tag and class and the same face class; CONTROL for html
and richtext outside a grid column keeps the `h1` and the document
classes.
-
`ui/packages/plugin-grid/src/__tests__/ObjectGrid.richTextOneLine-12480.test.tsx`
(the grid's rich-text one-line harness, new top-level describe): through
`ObjectGrid`, html and richtext cells whose value starts with a heading
draw the cell face and `tbody` holds no `h1`..`h6`.
- Existing test changed because of this fix: in the same 12480 file, the
case "10 rows with a markdown, an html and a richtext column" asserted
the html cell inside the clamp holds an `h2`; it now asserts the heading
is drawn as `[data-html-heading]` reading `Title`. This is the behaviour
the card asks to change. No other existing test was edited.
## Acceptance notes
- File surface: the dispatch named `fields/src/**/__tests__/` for tests.
The 12480 file under `plugin-grid` was outside it and had to change,
because one of its assertions pinned the old heading element in a grid
cell. The grid-level pin for this card went into that same file as a
top-level describe, per the shared-harness rule.
- Not changed, noted: the doc comment on
`CellRendererProps.inGridColumn` in `ui/packages/fields/src/index.tsx`
still says the prop is read by the `date` and `markdown` cells; the
`html` / `richtext` cell now reads it too. That file is outside this
card's file surface, so the comment is left for the seat to route.
- jsdom has no layout. The pins check the elements and classes that the
row height depends on. The pixel readings are below.
## Verification
Read these first, by risk:
1. `ui/packages/fields/src/widgets/sanitizedHtml.tsx`: the `components`
option on `toJsxRuntime`. This is the sanitizer module, so check that
the map is applied after sanitisation and the schema is untouched.
2. `ui/packages/fields/src/widgets/richTextDisplay.tsx`:
`HtmlCellRenderer` and `cellFaceHeadings`.
3. `ui/packages/fields/src/widgets/MarkdownContent.tsx`: now imports the
shared face.
Two-minute check: open any object list whose `html` or `richtext` field
holds a value starting with a heading. The row should be as tall as its
neighbours, with the heading in bold at the cell's text size. Open the
record: the heading should be full size.
<details><summary>Measurement (card item 1): through ObjectGrid, before
and after</summary>
Method: four rows rendered through `ObjectGrid` in jsdom: html holding
an h1 heading plus a paragraph, richtext holding the same, markdown
starting with a heading, and a plain row. The resulting table markup was
then laid out in Chromium (`/opt/pw-browsers/chromium`, 1200 px wide)
with the console stylesheet compiled from
`ui/apps/console/src/index.css` (Tailwind 4 plus typography).
Before (origin/main 87c7bba): `tbody` holds an `H1` in the html row and
in the richtext row. Row heights: html 45 px, richtext 45 px, markdown
36 px, plain 36 px. The heading is drawn at font-size 30px, line-height
36px.
After (4f80ba1): `tbody` holds no heading element. Row heights: 36 / 36
/ 36 / 36 px. The heading is a `P` at font-size 14px, line-height
17.5px, the same as the markdown cell's heading.
</details>
<details><summary>Ablation (one, on the tested behaviour)</summary>
Mutation via `scripts/ablation-replace.mjs`: in `HtmlCellRenderer`, the
line that picks `cell` when `inGridColumn` is set was changed to always
pick `document` (anchor 1 → 0, blob baccb82 → 9b850e05). Run: the 36344
and 12480 files. Result: 6 failed, 8 passed. The failures were the four
html/richtext grid-column cases in the fields harness, the updated 12480
assertion, and the new grid pin. The controls stayed green: the markdown
cases and the html/richtext document-face cases. After restore the blob
equals HEAD (baccb82) and `git diff HEAD` is empty.
</details>
<details><summary>Local runs (head 1b5c106, after merging
origin/main)</summary>
- Dependency closure `turbo run build
--filter=@object-ui/plugin-grid^...`: 53/53 tasks, lock VERDICT
command-exit 0.
- `pnpm --filter @object-ui/fields type-check` and `pnpm --filter
@object-ui/plugin-grid type-check`: exit 0 (both test tsconfigs list the
changed test files).
- `vitest run packages/fields/` plus the 12480 file: Test Files 323
passed, 1 skipped; Tests 4896 passed, 7 skipped; VERDICT command-exit 0.
- Before the merge, at 4f80ba1: `vitest run packages/fields/
packages/plugin-grid/`: Test Files 629 passed, 1 skipped; Tests 7604
passed, 7 skipped; VERDICT command-exit 0.
- `dispatch-gates.mjs --commands` at 1b5c106: 38 families, each run,
all exit 0. `--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED.
- `ui` `check:spec-symbols` exit 0; `check:new-line-citations`: 0 new
citations.
- `test:repo`: owned by CI, not run locally.
</details>
Session: https://claude.ai/code/session_01ADHkmRGDrq6JSytBsNFabU
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent abe95a9 commit 06c3e5a
6 files changed
Lines changed: 211 additions & 43 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 | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 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 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
7 | 13 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 20 | + | |
| 21 | + | |
42 | 22 | | |
43 | 23 | | |
44 | 24 | | |
| |||
49 | 29 | | |
50 | 30 | | |
51 | 31 | | |
52 | | - | |
| 32 | + | |
53 | 33 | | |
54 | 34 | | |
55 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 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 | + | |
42 | 91 | | |
43 | 92 | | |
44 | 93 | | |
| |||
129 | 178 | | |
130 | 179 | | |
131 | 180 | | |
132 | | - | |
133 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
134 | 191 | | |
135 | | - | |
| 192 | + | |
136 | 193 | | |
| 194 | + | |
137 | 195 | | |
138 | | - | |
139 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
140 | 201 | | |
141 | 202 | | |
142 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
143 | 211 | | |
144 | 212 | | |
145 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
152 | 157 | | |
153 | | - | |
| 158 | + | |
154 | 159 | | |
155 | 160 | | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
159 | 164 | | |
160 | | - | |
| 165 | + | |
161 | 166 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
0 commit comments