Repository navigation
Commit bdd5176
fix(fields): the lookup picker fits the room it is given, marks a cut row, and lets option previews wrap (#34381)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9QSmT6s2ZTGps4fXHsTwFbT)_
Fixes #34362
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:查找字段快选弹层的选项列表不再固定 16rem 高:弹层不超过 Radix
报告的可用高度(搜索框保持高度,列表占剩余空间,上限仍是
16rem);列表上下还有更多选项时,那一侧边缘渐隐,被切开的行读作「可继续滚动」;每个选项的副标题放不下时整列换到第二行(最多两行),不再把邮箱和所属客户一起截断;仍被截断的文本值悬停可见全文(title)。
- **为什么改**:实测根因不是对话框挡住了翻转。弹层本就 portal 到 body,Radix 在对话框里照常翻到空间更大的一侧;「只露
4½ 行、最后一行半截」是固定 16rem(256px)列表高度对上 56px
行高的必然结果,在哪里打开都一样,且没有任何滚动提示。窗口较矮、两侧都放不下时,弹层还会超出屏幕。
- **风险与回滚**:只改 `@object-ui/fields` 的 LookupField
弹层/列表/选项行,无契约与服务端改动;未改共享 `popover.tsx`。副标题由单行变为最多两行,选项行可能变高,16rem
内可见行数会减少(两行副标题时约 3½ 行)。回滚即 revert 本 PR。
- **先看**:① `ui/packages/fields/src/widgets/LookupField.tsx` 的
`fitPreviewLine`(换行、行数上限、换行列去掉分隔点、截断值写 title);② 同文件 `PopoverContent` 与
listbox 的类名及 `listMore` 渐隐;③ 测试文件
`LookupField.previewBadges-13123.test.tsx` 改写的布局模型。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/fields/src/widgets/LookupField.previewBadges-13123.test.tsx`,预期
17 个测试全过。
- **需要你做的**:无,席位落地。
## Root cause (measured)
Measured in Chromium with the real `LookupField` and the real `Dialog`,
bundled from source (the bundling of
`e2e/permission-field-panel-scroll.spec.ts`, real Tailwind theme),
inside a dialog with the action dialog's classes (`flex max-h-[90vh]
flex-col`), at 1280×800, with ten contacts previewing Email and Account
like the card's picker. The probe was a one-off and is not committed.
- **The popover does flip inside a dialog.** `PopoverContent` already
renders through a Radix portal into `body`, so no dialog body clips it,
and Radix's default `flip` measures against the viewport. With the field
near the dialog's bottom (space below 259 / 179 / 121 px, above 501 /
581 / 639 px) the popover opened on top every time (`data-side="top"`),
fully inside the viewport. No collision boundary and no portal problem.
- **The "4½ rows, last one cut mid-row" is the list's fixed
`max-h-64`.** The list was 256 px whatever the room. An option with a
one-line preview is 56 px tall, so the fifth row always showed 32 of its
56 px: its name, not its preview, exactly as the card describes, below
or above the field alike, with nothing saying the list scrolls.
- **The cap also ignored the room it was given.** At 1280×480, with 179
px below and 261 px above, the 306 px popover flipped up and ran 49 px
off the top of the screen (`--radix-popover-content-available-height`
read 257 px; the list ignored it).
- **The subtitle cut both fields because it was one row.** Two text
columns side by side each shrink to share one row, so `Email:
emily.davis@starkmed.e…` and `Account: Stark Medic…` were both cut, and
the account name that tells same-named contacts apart was lost.
After the fix, same probe: the popover still opens on top at 259 / 179 /
121 px below; at 1280×480 it is 257 px tall at `top: 0` (inside the
viewport) with the list at 207 px; every preview shows the full email on
its first row and the full account on its second; the cut row at the
list's bottom sits under a fade.
## What changes
- `PopoverContent` (in `LookupField`, not the shared `popover.tsx`):
`flex flex-col max-h-(--radix-popover-content-available-height)`. The
search row, the error state and the loading state are `shrink-0`; the
list (in a `relative flex min-h-0 flex-col` wrapper) is `max-h-64
min-h-0`, so it takes what the search row leaves, up to the same 16rem.
Radix's default flip is kept: it still moves the popover to the side
with more room whenever the whole popover does not fit below.
- Scroll cue: `listMore` tracks whether options continue above or below
the list's visible box (read after every commit, on scroll, and from a
`ResizeObserver` on the list, attached by a callback ref); each edge
with more past it draws an `aria-hidden` gradient
(`lookup-list-more-above` / `lookup-list-more-below`). The list carries
`scroll-py-6`, so the arrow keys' `scrollIntoView({ block: 'nearest' })`
stops an option clear of the fade.
- Option preview: the line is `flex-wrap` (`gap-x-1 gap-y-0.5`).
`fitPreviewLine` now hides trailing segments while the line overflows
its width OR its shown segments span more than `LOOKUP_PREVIEW_MAX_ROWS`
(2) rows, read off the segments' `offsetTop`. So a column that does not
fit beside the one before it moves whole to the second row, and a column
that does not fit in two rows leaves whole, with every column after it.
A shown segment that opens a row hides its leading `·`. A text value
(`data-lookup-preview-text`) whose box is narrower than its content gets
its full text as `title`; one that fits has none. The objectui#13123
rules stand: a badge column never shrinks, a text value never shrinks
below its label.
- The ORDER of the previewed columns is untouched: it is the app's
authored config.
- Changeset: `.changeset/34362-lookup-picker-room.md`
(`@object-ui/fields`: patch).
## Tests
All in the existing shared harness file
`LookupField.previewBadges-13123.test.tsx` (jsdom has no layout, so the
pins read classes, attributes and stubbed boxes, not pixels):
- New `describe('LookupField picker popover: bound to the room it is
given (objectstack#34362)')`: the popover is portaled out of the field
into Radix's popper wrapper; it carries `flex`, `flex-col` and
`max-h-(--radix-popover-content-available-height)`; the search row is
`shrink-0`; the list is `min-h-0 max-h-64 overflow-y-auto` in a
`min-h-0` wrapper; the below / above fades follow a stubbed scroll box
through scroll to the end and back; no fade when every option fits; the
list carries `scroll-py-6`.
- New `describe('LookupField option preview: secondary columns stay told
apart (objectstack#34362)')`: the line is `flex-wrap`; a column that
opens the second row drops its separator, one beside its predecessor
keeps it, and every separator stays on one row; a cut text value gets
its full text as `title`, a whole one and a badge get none.
- **Forced edit to existing tests**, named: the layout model behind
`describe('LookupField option preview: a column the line cannot hold
leaves whole (objectui#13123)')` (renamed "…the rows cannot hold…") now
wraps segments onto rows (`offsetTop` stubbed) instead of modelling one
row, because the line now wraps. Its cases moved with the model: at 280
px all three columns show (revenue wraps to row two, was dropped); at
180 px status and industry show (one column a row, the third row is one
too many; was status only); 600 px and 100 px are unchanged. The resize
case now goes 180 → 600 → 100 px (`[status, industry]` → all → none).
Every assertion of the three "badge never cut / text still truncates /
segment whole" tests above it is unchanged.
## Acceptance notes
- None filed.
- The 16rem list cap is kept. With a two-row preview an option is 74 px,
so about 3½ options show in 16rem where 4½ did; the fade marks the cut.
Whether the cap should grow is a product call left open in the report,
not made here.
- No docs page describes the typeahead's placement or preview layout
(`content/docs/data-modeling/field-types.mdx` describes the picker's
features only), so no docs change is owed.
- `popover.tsx` (shared by every popover) is not touched: the cause was
in the lookup's own list, not in the primitive.
## Verification
<details><summary>Tests</summary>
- `pnpm --dir ui exec vitest run
packages/fields/src/widgets/LookupField.previewBadges-13123.test.tsx` →
Tests 17 passed.
- `pnpm --dir ui exec vitest run packages/fields/ --maxWorkers=2` → Test
Files 306 passed, 1 skipped; Tests 4633 passed, 7 skipped.
- `pnpm --filter @object-ui/fields run type-check` (`tsc --noEmit && tsc
-p tsconfig.test.json`) → exit 0.
- `pnpm --dir ui exec eslint` on the two changed files → exit 0 (0
errors; the warnings are pre-existing lines). `pnpm --dir ui run
check:new-line-citations` → 0 new citations.
</details>
<details><summary>Ablations (scripts/ablation-replace.mjs, mutation
proven on disk, each restored to HEAD blob 010d418)</summary>
- A1 drop `max-h-(--radix-popover-content-available-height)` from the
popover → "caps the popover…" red (1 failed / 16 passed).
- A2 drop `min-h-0` from the list → "caps the popover…" red (1 / 16).
- A3 `below:` always false → "marks the list edge…" red (1 / 16).
- A4 delete the row cap (`|| previewRowsOf(segments) >
LOOKUP_PREVIEW_MAX_ROWS`) → the 180 px case and the resize case red (2 /
15).
- A5 delete `if (separator && opensRow) separator.hidden = true;` →
"drops the separator…" red (1 / 16).
- A6 write no `title` on a cut value → "gives a text value cut short…"
red (1 / 16).
- A7 drop `flex-wrap` → "lets the preview wrap…" red (1 / 16).
</details>
<details><summary>Derived gate families</summary>
Head `c3c5b8cc`, `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 38 commands, all exit 0. `--ran`
reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN.
```text
node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0
node scripts/check-adr-0087-registration.mjs --self-test :: exit 0
node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0
node scripts/check-closing-keyword-parity.mjs :: exit 0
node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0
node scripts/check-comment-mask-corpus.mjs :: exit 0
node scripts/check-empty-changeset.mjs --base origin/main :: exit 0
node scripts/check-empty-changeset.mjs --self-test :: exit 0
node scripts/check-sdui-manifest.mjs :: exit 0
node scripts/check-sdui-manifest.mjs --self-test :: exit 0
node scripts/ci/snapshot-next.mjs --self-test :: exit 0
node scripts/pm/check-governed-queue-guard.mjs --self-test :: exit 0
node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0
node scripts/release-pending-publish.mjs --self-test :: exit 0
pnpm --dir ui exec vitest run scripts/ :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm check:adr-anchors :: exit 0
pnpm check:changeset-gate-self-tests :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:dispatcher-error-vocabulary :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:engine-double-contract :: exit 0
pnpm check:gitlink-declared :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:published-files :: exit 0
pnpm check:query-options-erasure :: exit 0
pnpm check:refd-timer-probe :: exit 0
pnpm check:registry-log-declared :: exit 0
pnpm check:rest-log-spy-declared :: exit 0
pnpm check:skill-identifier-liveness :: exit 0
pnpm check:test-source-alias :: exit 0
pnpm check:tier-file-adoption :: exit 0
pnpm check:type-check-coverage :: exit 0
pnpm check:type-check-debt :: exit 0
pnpm check:undeclared-dep-imports :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
```
Every family CI runs is read from this PR's check-runs, not re-run here.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSg4bMFcuXXpNikRnL)_
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 495a79c commit bdd5176
3 files changed
Lines changed: 296 additions & 37 deletions
File tree
- .changeset
- ui/packages/fields/src/widgets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
| 183 | + | |
180 | 184 | | |
181 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
182 | 212 | | |
183 | | - | |
184 | 213 | | |
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | 217 | | |
195 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
196 | 222 | | |
197 | 223 | | |
198 | 224 | | |
| |||
216 | 242 | | |
217 | 243 | | |
218 | 244 | | |
219 | | - | |
| 245 | + | |
220 | 246 | | |
221 | | - | |
222 | | - | |
223 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
224 | 251 | | |
225 | 252 | | |
226 | 253 | | |
| |||
244 | 271 | | |
245 | 272 | | |
246 | 273 | | |
247 | | - | |
| 274 | + | |
248 | 275 | | |
249 | 276 | | |
250 | 277 | | |
251 | 278 | | |
252 | 279 | | |
253 | 280 | | |
254 | | - | |
| 281 | + | |
255 | 282 | | |
256 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
257 | 402 | | |
258 | 403 | | |
0 commit comments