Repository navigation
Commit 896bfc4
fix(plugin-dashboard): draw a declared gap: 0 with no gap (#37059)
Fixes #36912
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 搭仪表盘的人在仪表盘里写了组件间距为零后,卡片现在会紧贴着画出来,以前仍隔着一段默认间距;没写间距的仪表盘不变。
- 属于仪表盘渲染的修正:规范允许间距为零,渲染器却把零当成没写。
- 出错时只是卡片之间的空隙不对,不丢数据,可以直接撤回。
- 无
## What changes
`ui/packages/plugin-dashboard/src/DashboardRenderer.tsx` read the
declared gap as `schema.gap || 4`, so a declared `gap: 0` (legal: `gap:
z.number().int().min(0).optional()`,
`packages/spec/src/ui/dashboard.zod.ts`) fell through to the default 4
(1rem). It now reads `schema.gap ?? 4`; only an absent `gap` takes the
default.
Every reader of the declared gap in `@object-ui/plugin-dashboard`, read
at `b01d8f97`:
- `DashboardRenderer.tsx` line 409, `const gap = schema.gap || 4` - the
only reader of `schema.gap`; fixed here.
- `DashboardRenderer.tsx` `gapPx={gap * 4}` on the design-mode resize
handle - derives from the same `gap` constant, so it now sees the
declared zero too; no `||` of its own.
- `DashboardRenderer.tsx` desktop grid root `gap: gap * 0.25 rem` inline
style - derives from the same constant; this is what the test reads.
- The mobile body (`flex flex-col gap-4`, metric grid `gap-3`) does not
read `schema.gap` at all: fixed Tailwind classes, no `||`, unchanged.
Noted below.
- `index.tsx` declares `{ name: 'gap', type: 'number' }` as a block
input; `DashboardConfigPanel.tsx` edits it. Neither defaults it.
## Live observation
The issue asks for a live measurement first. A browser on a dev server
needs a full monorepo build plus the Console build in a container shared
with two sibling dev agents, where each verify-lock call already queued
4 to 9 minutes; I judged that impractical here and took the reading the
dispatch allows instead: the real `DashboardRenderer`, rendered by the
new test, reading the grid root's inline `gap` style.
| schema | before (`b01d8f97` renderer) | after |
|:---|:---|:---|
| `gap: 0` | `1rem` (test red: Expected "0rem", Received "1rem") |
`0rem` |
| `gap` absent | `1rem` | `1rem` |
| `gap: 2` | `0.5rem` | `0.5rem` |
## Tests
New
`ui/packages/plugin-dashboard/src/__tests__/DashboardRenderer.gapZero-36912.test.tsx`:
renders `gap: 0` and asserts the grid root's style `gap` is `0rem`, with
the absent-`gap` control (`1rem`) and a non-zero case (`0.5rem`). It was
committed before the fix and run red against the unfixed renderer (1
failed, 2 passed), then green after (3 passed).
## Acceptance notes
- The mobile layout ignores the declared `gap` entirely (fixed `gap-4` /
`gap-3`). That is the phone layout's own spacing, not a `||` reader, and
outside this card; not filed.
- Outside this package,
`ui/packages/components/src/renderers/action/action-bar.tsx` reads
`schema.gap || 'gap-2'`, but its `gap` is a class string, where only an
empty string falls through; not the same defect, not filed.
## Verification
Two-minute check: `cd ui/packages/plugin-dashboard && pnpm exec vitest
run --root ../..
packages/plugin-dashboard/src/__tests__/DashboardRenderer.gapZero-36912.test.tsx`
- expect 3 passed; revert line 409 to `||` and the `gap: 0` case reads
`1rem`.
Read first: `DashboardRenderer.tsx` around line 409 (the one-line
change), then the new test.
<details><summary>Local readings at 282baba</summary>
- `@object-ui/plugin-dashboard` tests: Test Files 217 passed (217),
Tests 2100 passed, 6 skipped (2106), TEST_EXIT=0.
- `@object-ui/plugin-dashboard` type-check (turbo, with its dependency
builds): Tasks 54 successful, 54 total; lock VERDICT command-exit 0.
- `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed, 2
skipped (174); Tests 5129 passed, 2 skipped; VERDICT command-exit 0.
- `dispatch-gates --commands` derived 38 families on this diff; all 38
exited 0; `--ran` reconciliation: 38 run, 0 NOT-MEASURED (a derived
zero).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 67154ed commit 896bfc4
3 files changed
Lines changed: 72 additions & 1 deletion
File tree
- .changeset
- ui/packages/plugin-dashboard/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 | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| |||
| 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 | + | |
0 commit comments