Uh oh!
There was an error while loading. Please reload this page.
fix(charts): ChartContainer 的 min-size 兜底改为显式合并,不再被调用方 style 整体覆盖 - #3956
Merged
Conversation
… consumer style can't revoke it
`style` was written as an explicit JSX attribute ABOVE `{...props}`, and `props`
still carried the consumer's `style` (only id/className/children/config/
disableSettleRemount are destructured out). A later same-named JSX attribute
replaces an earlier one, so any caller passing `style` replaced the whole object:
`minHeight: 280` and `minWidth: 0` both vanished and the `...props.style` merge
written inside it never ran once — dead code that read as a guarantee.
`style` is now destructured out of the rest props and merged explicitly, so
precedence is stated in code rather than decided by attribute order.
Precedence: the author's explicit size wins. Spreading `{...props}` first and
merging unconditionally would trade this bug for its mirror image (a 280 floor
overriding an authored `height: 100`), so the height half of the fallback applies
only when the consumer style declares neither `height` nor `minHeight`, and the
width half only when it declares neither `width` nor `minWidth`.
Pinned in both directions in ChartContainerImpl.styleMerge.test.tsx.
Fixesobjectstack-ai/objectstack#7026
Co-Authored-By: Claude <noreply@anthropic.com>The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
yinlianghui
commented
Aug 9, 2026
CollaboratorAuthor
PM 验收(session_01GTRjn8xBqp75dk7kFupVRt):通过,转 ready 并挂 auto-merge。os#7026 落地。 核验记录(head
out-of-scope:#3339 上的范围扩大评论(ECONNREFUSED 噪音旁证)处置得当,未开孪生单。 Generated by Claude Code |
yinlianghui
marked this pull request as ready for review
August 9, 2026 17:05
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixesobjectstack-ai/objectstack#7026
机理
ChartContainerImpl.tsx把style写成显式 JSX 属性,而{...props}展开在它下面一行;props是ComponentProps< "div" >解构后的 rest,只摘掉了id/className/children/config/disableSettleRemount——style还在里面。JSX 里后写的同名属性整体覆盖先写的,所以只要调用方传了style,整个 style 对象就被替换:minHeight: 280与minWidth: 0一起消失,而写在里面的...props.style那次合并从未执行过一次。它是死代码,却让读代码的人以为兜底一直在。这个兜底不是装饰:它是为了让 Recharts 的 ResponsiveContainer 永远有一个非零盒子可量。dashboard widget 覆盖掉容器的
h-[350px]类、又把 chart 塞进没有显式子高度的 flex/grid 时,盒子停在 0,Recharts 量到width/height = -1,图渲染不出来 —— 正是当年加这道兜底要防的场景。改法
把
style从 rest props 里显式解构出来、单独合并,于是"谁覆盖谁"写在代码里,而不是靠 JSX 属性顺序这种一眼看不出来的机制;{...props}也再也碰不到style。合并语义:作者的显式尺寸赢。 只是"把
{...props}挪到前面、无条件合并"会把这个 bug 换成它的镜像 ——minHeight: 280与作者写的height: 100并存时,CSS 里 min-height 赢,作者的 100 被静默压成 280。所以兜底的每一半都只在调用方 style 两个对应键都没声明时才注入:height也无minHeight时才注入minHeight: 280;width也无minWidth时才注入minWidth: 0;undefined/null记作"未声明";注释也改成与实现一致:说清何时兜底、何时让位于作者的显式尺寸,并记下原来的顺序依赖为什么是死代码。
行为变化面(刻意收窄)
style的调用方:逐字节不变。style带高度的调用方 —— 今天树里唯一的形状,即AdvancedChartImpl的containerProps转发ChartConfig.height—— 保留它声明的高度,同样不变,额外多拿回minWidth: 0那一半。style不含尺寸键时(margin、padding、aspect-ratio,以及以后任何走同一条containerProps路径的容器级呈现键)现在保有 min-size 兜底,而不是把它一起静默带走。钉子与反向验证
两方向都钉,因为单方向的钉子会被镜像改法一样满足:
{ margin: 8 })仍带min-height: 280/min-width: 0,且 margin 透传style: { height: 100 }渲染成 100 且无min-heightstyle: { minHeight: 100 }低于兜底也赢style: { width: 400 }不注入 minWidth、高度那半仍兜底height: undefined记作未声明,仍兜底反向验证做了两次,方向都是先预判后跑:
2 failed | 5 passed,正是第 3、5 条。所以这两条钉子是承重的,不是陪衬。范围
只动
ChartContainerImpl.tsx+ 新测试 + changeset。⛔ 没动AdvancedChartImpl的containerProps生产侧;⛔ 没碰在飞的 chart block 外壳文件;⛔ 没碰 releases/。packages/components/src/ui/chart.tsx里那份上游 shadcn 的 ChartContainer 副本已核查:它根本没有 min-size style,也没有显式style属性,不存在同一 bug(且属 No-Touch 区)。Generated by Claude Code