Repository navigation
Commit a60740a
fix(components): re-measure the record header's width fold on another record (#36260)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XTRdLmK9YYgMSCJ7NH2PuUY)_
Fixes #35997
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户在记录页或抽屉里用上一条/下一条切换记录时,顶栏操作按钮会按新记录重新排布:从操作多的记录切到操作少的记录后,放得下的操作重新直接显示(最多三个),不再被多余地收进「更多」菜单。
- 属于记录页顶栏「最多显示三个操作、其余收进更多」那项改进的收尾,替经常翻记录的业务用户解决按钮莫名变少的问题。
- 出错时最坏是顶栏某个操作仍被收进「更多」菜单里(点开仍可用),不影响数据;只是界面渲染变化,可直接撤回。
- 无
## What changes
- `PageHeaderActions` (record header bar, `fitWidth`): the width cap the
row's wrapping lowers is now stored with the key it was measured on, the
record id from the record context plus the names of the page's own
inline-eligible actions. A render whose key differs (another record, or
a changed action set) draws the full budget (3, or the page's
`maxVisible`), and the existing layout effect measures again, so a row
that still wraps folds again one action at a time. The host-resize path
(`ResizeObserver` clearing the cap) is unchanged.
- The key is a string, so an equal record and action set never re-arms
the fold and nothing loops: the cap is only set while the row wraps and
the drawn budget is above the floor, as before.
- The cap rule and the fold rule themselves (at most 3 inline, the
primary never folds, host Edit never folds) are untouched.
Read first, by risk:
1. `ui/packages/components/src/renderers/layout/containers.tsx` — the
hunk at "A cap holds only for the record and action set it was measured
on" (the key and the keyed read of the cap).
2. same file — the layout effect writing `setWidthCap({ key, cap: inline
- 1 })`.
3.
`ui/packages/components/src/__tests__/page-header-record-bar-35593.test.tsx`
— the new top-level describe "re-measures the width fold on another
record (objectstack#35997)".
Two-minute verification: `pnpm --dir ui exec vitest run
packages/components/src/__tests__/page-header-record-bar-35593.test.tsx`
from the repo root; expect 17 passed, among them "a record with fewer
actions that fit draws min(maxVisible, count) again" and its CONTROL.
## Tests
- New pins in the existing shared harness for this row's width fold, as
a new top-level describe (the harness file already pins the fold for the
header bar, so the pins join it rather than a new file):
- record A (four actions, the row wraps) folds to the primary; the host
steps to record B (two actions, the row fits) by re-rendering the same
tree with another record id and data: B draws both of its actions
inline, i.e. min(maxVisible, count) = 2, with Edit kept.
- CONTROL: the same switch where B's row still wraps folds B again to
the primary (the fold still works after the reset).
- Ablation (one-off, not kept): the keyed read reverted to an unkeyed
one (`widthCap ? widthCap.cap : null`) through
`scripts/ablation-replace.mjs`: the first pin goes red with `expected [
'Convert', 'Edit', 'More actions' ] to include 'Log call'`, 1 failed /
16 passed; restore verified by the tool (blob equals HEAD, `git diff
HEAD` empty). The test imports the renderer from source, so no build
sits between the mutation and the run.
## Acceptance notes
- Zone measurement: the record page and the drawers do not remount the
view between records (the view's own comment on its feed key says no
mount site passes a `key=`; the drawers swap `recordIdOverride`), so the
row instance and its cap do survive a record switch; the defect
reproduced in the new pin before the fix (the ablation leg is that
reproduction).
- The reset key carries the record id as well as the action names, as
the card asks (record id or action list change). A switch between two
records with the same action set therefore also re-measures once; that
costs one extra synchronous layout pass and lands on the same fold.
## Verification
Every reading below is at head `621ca521`, taken under
`scripts/pm/os-verify-lock.sh` (shared box).
<details><summary>Target file and package (green)</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/components/src/__tests__/page-header-record-bar-35593.test.tsx`:
Test Files 1 passed (1), Tests 17 passed (17).
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/components/`:
Test Files 503 passed, 1 skipped (504); Tests 4847 passed, 24 skipped
(4871); lock VERDICT command-exit 0.
- `pnpm --filter @object-ui/components run type-check` (both `tsc
--noEmit` and `tsc -p tsconfig.test.json`; the test project lists the
edited test file): lock VERDICT command-exit 0.
- Dependency closure built first: `turbo run build
--filter='@object-ui/components^...' --concurrency=2`, 48 of 48 tasks
successful.
</details>
<details><summary>Ablation (red as expected, restored)</summary>
- Mutation: the keyed read of the cap replaced by an unkeyed one, via
`scripts/ablation-replace.mjs` (anchor 1 to 0, blob 4de451f to
cd81ae01).
- Run: 1 failed, 16 passed; the failing case is "a record with fewer
actions that fit draws min(maxVisible, count) again" with `expected [
'Convert', 'Edit', 'More actions' ] to include 'Log call'`. The CONTROL
stays green under the mutation, as a control should.
- Restore: blob after restore equals HEAD (4de451f), `git diff HEAD`
empty.
</details>
<details><summary>Derived gates (dispatch-gates, 38 of 38 exit
0)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands` derived 38 commands
for this diff; all 38 ran and exited 0, among them `check:nul-bytes`,
`check:published-files`, `check:cross-package-test-inputs`,
`check:test-source-alias`, `check:type-check-coverage`,
`check:type-check-debt`, `check:sdui-manifest`,
`check-adr-0087-registration --base origin/main`, `check-empty-changeset
--base origin/main`, `check-changeset-no-major --base origin/main` and
`pnpm --dir ui exec vitest run scripts/` (Test Files 172 passed, 2
skipped; Tests 5122 passed, 2 skipped).
- `--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN,
every line carrying its exit code.
- Outside the derivation: `pnpm check:changeset-fixed` exit 0 (its
roster lives under `.changeset/`), and `pnpm --dir ui run
check:new-line-citations`: 0 new citations.
- Type-check lanes, the artifact-roster and wide-population families and
the repo-wide lint are CI's.
</details>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 76cb366 commit a60740a
3 files changed
Lines changed: 109 additions & 9 deletions
File tree
- .changeset
- ui/packages/components/src
- __tests__
- renderers/layout
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1987 | 1987 | | |
1988 | 1988 | | |
1989 | 1989 | | |
1990 | | - | |
| 1990 | + | |
| 1991 | + | |
1991 | 1992 | | |
1992 | 1993 | | |
1993 | 1994 | | |
| |||
2027 | 2028 | | |
2028 | 2029 | | |
2029 | 2030 | | |
2030 | | - | |
2031 | | - | |
2032 | | - | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
2033 | 2035 | | |
2034 | | - | |
| 2036 | + | |
2035 | 2037 | | |
2036 | 2038 | | |
2037 | 2039 | | |
2038 | 2040 | | |
2039 | 2041 | | |
2040 | | - | |
2041 | | - | |
| 2042 | + | |
| 2043 | + | |
2042 | 2044 | | |
2043 | 2045 | | |
2044 | 2046 | | |
| |||
2723 | 2725 | | |
2724 | 2726 | | |
2725 | 2727 | | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
2726 | 2732 | | |
2727 | | - | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
2728 | 2736 | | |
2729 | | - | |
| 2737 | + | |
2730 | 2738 | | |
2731 | 2739 | | |
2732 | 2740 | | |
| |||
0 commit comments