Repository navigation
Commit 057cedf
fix(plugin-detail): a related table in the record preview drawer draws instead of looping on its column cap (#37244)
Part of #37212
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:在列表右侧预览抽屉里打开记录时,「详情」中的相关子表(如商机的产品明细)正常显示,不再报「组件渲染失败」;完整记录页不变。
- 为什么做:产品负责人报告的高优先级缺陷。抽屉的详情栏很窄,子表要决定显示几列;它测量时读到的是上一次的表格,于是在「1 列」和「2
列」之间来回切换,直到浏览器报无限更新。该问题只在 18.6.0
之后构建的控制台里出现,所以本合并不直接关卡,待租户实际使用的控制台版本确认后再关。
-
出错会怎样:只影响窄栏子表决定列数的时机;最坏是窄栏里显示的列数不对,或隐藏某列后再缩窄时表格被截断且没有「全部列」提示。数据不受影响,可直接撤回本改动。
- 要你做什么:无
## What changes
**Root cause.** A related list drawn as a record's body table (the 「详情」
section's master-detail table) leaves out the trailing columns that do
not fit whole in its column, through the `bodyTableColumnCap` state in
`RelatedList`. The layout effect that reads the cap lists the cap itself
in its deps ("re-read once the table draws the columns that fit"), so
every cap change re-reads synchronously, in the same commit chain. But
`data-table` adopts a new `columns` prop one render later: it copies the
prop into its own state in an effect. So the re-read measures the table
still drawn for the previous cap. The columns already handed away carry
no inline min-width there, so the read also falls back to their stale
pre-draw estimates.
At the preview drawer's default 460 px width, the details column is a
326 px scroll box. Measured in the browser on the CRM example
(opportunity, line items with a lookup, a select, a percent and a text
column added):
- Cap 1 handed, six columns still drawn: the actions cell sits at its
natural 66 px, so the read says 2 fit.
- Cap 2 handed, one column still drawn: the table stretches and the
actions cell is 118 px, so the read says 1 fits.
That repeats every commit until React stops it with `Maximum update
depth exceeded` (React error 185). data-table's own layout effects run
first in each commit, so its error boundary takes the throw and reports
`Component "data-table" failed to render`. The full page's details
column fits every column, so the cap never moves there.
**Fix** (`ui/packages/plugin-detail/src/RelatedList.tsx`, the body-table
read):
- The list records, in a ref, how many columns the table last drew
exactly as handed: the hand-over it has adopted.
- A read is skipped only while the table still draws that adopted count
(the same leading run of the list's columns), but a different count was
handed. That is the one-render adoption lag. The existing cells
`MutationObserver` reads again when the table re-draws.
- A table that draws a run of its own choosing is still read, for
example after "Hide column" from its header menu. So a later narrowing
still leaves columns out and shows the overflow cue, as on main.
- The adopted count resets with the widths when the list's column set
changes.
Edited files: `ui/packages/plugin-detail/src/RelatedList.tsx`,
`ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx`,
`.changeset/37212-drawer-body-table-column-cap.md`.
`recordDrawerStack.tsx` and `data-table.tsx` are untouched.
**Which builds carry the defect.** The cap and its self-triggering read
arrived with `d19d87529d` (2026-11-20). Master-detail children became
「详情」 body tables by default with `9b6db730b2`, and the side preview
opened 460 wide with `aad35e6885`.
- `@object-ui/*@18.6.0` / `@objectstack/console@18.6.0` resolve to
`958ee03594`, which has none of these. `git merge-base --is-ancestor
d19d875 958ee03` exits 1. The control leg `958ee03594~5` exits 0.
`RelatedList.tsx` there has no `bodyTableColumnCap`, and its one
body-table effect has deps `[bodyTableDrawn, isMobile]`.
- At `958ee03594` I booted the CRM example and drove the preview drawer
with stock line items and with the widened shape, at the default width
and at 380 to 800 px. There was no React error 185 at any width: the
body table draws every column and scrolls.
- The npm `next` build `0.0.0-next-20261125013212` has `gitHead`
`a1b26ff907` (2026-11-25T00:16Z) for `@objectstack/console`,
`@object-ui/console` and `@object-ui/plugin-detail`. `d19d87529d` is an
ancestor of it (exit 0), and its `RelatedList.tsx` and `data-table.tsx`
are identical to this PR's base.
- Two hotcrm-lane cards filed today, from the same product owner's
reports, measured a booted HotCRM on server 18.6.0 with that console.
The card's own text does not name the tenant's console build.
**Closing arrangement.** This PR is the platform half. The card stays
open until a reading on the reporting tenant names its console build
(the build's version, or its `gitHead` containing `d19d87529d`). Then,
after a console carrying this change is installed there, it needs a
second reading that the opportunity line items draw in the preview
drawer's 「详情」. The card closes on that reading.
**Responsibility.** Whose code: the platform's own console code (the
`@object-ui/plugin-detail` related list's body table, drawn by
`@object-ui/components` `data-table` inside the `@object-ui/app-shell`
record preview drawer). Existing platform path: none, since the full
page draws the same table fine. Who reaches it: every user who opens a
record with a related body table in the preview drawer, on a console
built after 2026-11-20, at a width where the cap sits between column
counts (the default 460 px with the line items above).
## Tests
Three cases in a top-level `describe` in the existing body-table
harness, `RelatedList.bodyTable-27055.test.tsx`: "RelatedList — a body
table in the record preview drawer settles its columns
(objectstack#37212)". They model the 326 px details column, where a
table narrower than its box stretches and the actions cell takes its
share. The real data-table is used, so its one-render column lag is the
real one, and the rows arrive from the data source as in the drawer.
- **Drawer case:** the table draws with no error boundary text and no
update-depth error, and settles on a leading run of the columns. Red on
the unfixed read, green after.
- **Hide then narrow:**
- At 1052 px, "Hide column" on the trailing column. The table then draws
three columns and omits none.
- Narrowed to 326 px, the read still runs: columns are left out and the
overflow cue is set. Red with round 0's guard, green after.
- **Full-page control** (1052 px): every column drawn, none left out, no
error. Green throughout.
<details><summary>Readings</summary>
- Round 0, red on unfixed main (`35079023b0`): the drawer case failed
with the error boundary's text in the DOM, and the control passed.
- Both body-table harness files at `e1b242fed2` (after merging
`origin/main`, closure rebuilt): `Test Files 2 passed (2)`, `Tests 41
passed (41)`.
- Ablation A1, the lag skip removed via `scripts/ablation-replace.mjs`:
- The anchor went 1 -> 0, blob `c199589f7aa5` -> `4b691f714dd4`.
- Result: `Tests 1 failed | 2 passed | 32 skipped (35)`; the red is the
drawer case.
- Restored: blob == HEAD `c199589f7aa5`, `git diff HEAD` empty.
- Ablation A2, round 0's guard put back:
- The anchor went 1 -> 0, blob `c199589f7aa5` -> `09c590c4173a`.
- Result: `Tests 1 failed | 2 passed | 32 skipped (35)`; the red is the
hide-then-narrow case.
- Restored: blob == HEAD `c199589f7aa5`, `git diff HEAD` empty.
- `@object-ui/plugin-detail` at `4008830387`: `pnpm --filter
@object-ui/plugin-detail type-check` exit 0. Whole package (`pnpm --dir
ui exec vitest run --maxWorkers=2 packages/plugin-detail/`): `Test Files
418 passed | 1 skipped (419)`, `Tests 3949 passed | 18 skipped (3967)`.
</details>
## Acceptance notes
- **Browser on main** (Console from `ui/` source over Vite against my
own CRM backend, line items widened as above), drawer width swept 380 to
800 px:
- Before: React error 185 and `failed to render` at 460 px only.
- After: every width draws the table, with no console error. The full
page draws all six columns.
- The stock three-column CRM line item does not reproduce on main.
- The widened columns were a temporary local edit, reverted, not part of
this PR.
- **The 326 px settle is path-dependent, and this PR does not change
that.** On open it settles at one column. After a widen-then-narrow it
can settle at two, because the read counts the actions cell's stretched
width as room the row actions need. The drawer pin asserts a leading
run, not a particular count.
- **Underlying property, left as is:** data-table adopts a new `columns`
prop a render later (its re-seed runs in an effect). Changing that would
move every table's column timing.
## Verification
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx
-t "settles its columns"` expects `3 passed`.
Read first, by risk:
1. `RelatedList.tsx`, the two guard lines at the top of the body-table
`read` and the adopted-count ref beside the column widths (the only
runtime change).
2. The new `describe` at the end of
`RelatedList.bodyTable-27055.test.tsx` (the layout model and the
hide-then-narrow case).
3. `.changeset/37212-drawer-body-table-column-cap.md`.
Security: none.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_
<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYmRepQK9DkZeU7F53D -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 8032d95 commit 057cedf
3 files changed
Lines changed: 189 additions & 2 deletions
File tree
- .changeset
- ui/packages/plugin-detail/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 | |
|---|---|---|---|
| |||
3665 | 3665 | | |
3666 | 3666 | | |
3667 | 3667 | | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
3668 | 3671 | | |
3669 | 3672 | | |
3670 | 3673 | | |
3671 | 3674 | | |
3672 | 3675 | | |
3673 | 3676 | | |
3674 | 3677 | | |
| 3678 | + | |
3675 | 3679 | | |
3676 | 3680 | | |
3677 | 3681 | | |
| |||
4077 | 4081 | | |
4078 | 4082 | | |
4079 | 4083 | | |
| 4084 | + | |
| 4085 | + | |
| 4086 | + | |
| 4087 | + | |
| 4088 | + | |
| 4089 | + | |
| 4090 | + | |
| 4091 | + | |
| 4092 | + | |
| 4093 | + | |
| 4094 | + | |
4080 | 4095 | | |
4081 | 4096 | | |
4082 | 4097 | | |
| |||
4096 | 4111 | | |
4097 | 4112 | | |
4098 | 4113 | | |
4099 | | - | |
| 4114 | + | |
4100 | 4115 | | |
4101 | 4116 | | |
4102 | 4117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
634 | 634 | | |
635 | 635 | | |
636 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
0 commit comments