Skip to content

form 组件的设计器默认值 defaultProps: { submitLabel: 'Submit', cancelLabel: 'Cancel' } 仍是英文字面量(本仓运行期无人读,但会绕过 #3272 的渲染期回落) #3394

Description

@yinlianghui

在实现 #3272(PR #3392)时发现,未在该 PR 内修改 —— 那一单的 PM 裁定明确划到「组件侧 prop 默认」,设计器元数据是另一个面。

现象

packages/components/src/renderers/form/form.tsx,ComponentRegistry.register('form', …) 的第二个参数(组件元数据)里:

inputs: [
  ...
  { name: 'submitLabel', type: 'string', label: 'Submit Button Label', defaultValue: 'Submit' },
  { name: 'cancelLabel', type: 'string', label: 'Cancel Button Label', defaultValue: 'Cancel' },
  ...
],
defaultProps: {
  submitLabel: 'Submit',
  cancelLabel: 'Cancel',
  ...
},

#3272 / PR #3392 把渲染期的英文默认值去掉了(解构不再写 submitLabel = 'Submit',改为 submitLabel ?? t('common.submit')),于是「作者没写 label」的表单会跟随会话语言。但上面这两处元数据默认值没动。

为什么记一条

defaultProps 在 packages/core/src/registry/Registry.ts 的注释里写的是 “Default props when dropped” —— 设计器把组件拖进画布时的初始 props。如果设计器把它落进作者的 schema,那么设计器生成的每一张表单都带着字面量 submitLabel: 'Submit',对渲染器而言这就是「作者显式写的值」,#3392 的渲染期回落按设计不会覆盖它(显式值逐字优先正是那一单钉住的不变量)。结果就是 issue #3272 描述的那种「不写 label 的作者被静默锁定英文」在设计器这条产出路径上原样保留。

同理 inputs[].defaultValue 会成为属性面板里预填的英文。

为什么标 finding 而不是直接当 bug 排期

今天本仓运行期够不到它:全仓 grep defaultProps,只有两处消费

位置 用途
packages/core/src/registry/Registry.ts:49 类型声明 defaultProps?: Record<string, any>
packages/core/src/registry/WidgetRegistry.ts:185 从 manifest 搬运到 widget 记录

packages/react / SchemaRenderer 渲染路径上没有任何一处读它,所以它今天不影响任何渲染文本。真正会不会咬人,取决于设计器侧(可能在 sibling 仓)拖拽落地时是否把 defaultProps 物化进 schema —— 这一点我没有验证,所以不敢断言严重度,按「填了让 PM 判」处理。

修法建议(先裁决再动)

不建议单独改 form 一个组件:defaultProps / inputs[].defaultValue 里埋英文字面量是全仓约 30 个 renderer 的统一写法(overlay/data-display/navigation 各 renderer 都是),只改 form 会造成一个不一致的孤例。真正要问的是:

  • A. 设计器元数据的默认值是否本来就该是「英文的、给设计器物化用的种子」,i18n 只管渲染期回落 —— 那么此条不是 bug,关掉即可,但值得在 Registry.ts 的 defaultProps 注释里写明这个边界,免得下一个人(尤其是 AI 生成的元数据)以为它会跟随语言。
  • B. 设计器不该物化「与渲染期默认值等价」的 prop(把 submitLabel 从 defaultProps 拿掉,让它保持未声明)—— 这是与 form.tsx 仍有一批用户可见的硬编码英文(全屏文本编辑对话框、Submit/Cancel 默认值、required aria-label) #3272 同向的收敛,但需要设计器侧确认「未声明」在属性面板里显示成什么(空?占位提示?),并且要一次扫全部 renderer,不是一行改动。

倾向 B,但这属于契约面/设计器交互的裁决,不该由某一单顺手做。

证据等级

静态证据(读 form.tsx 的注册元数据 + 全仓 grep defaultProps 的消费点),未做浏览器复现,也未验证设计器是否物化。「本仓运行期无人读 defaultProps」是可机械复核的事实;「设计器会不会把它写进 schema」是未验证的推断,也正是本条唯一的危害假设。

关联:#3272 / PR #3392。

Activity

  1. yinlianghui commented on Aug 6, 2026

    @yinlianghui
    CollaboratorAuthor

    发现分诊轮(持有):前提 live(defaultProps 仍英文字面),但仓内运行时零读取,危害假设依赖未证实的姊妹仓 designer 物化路径;需先裁 A/B 契约(defaultProps 是否属可物化面)再动 ~30 个 register()。(objectui 分片 PM,会话 session_01GTRjn8xBqp75dk7kFupVRt)


    Generated by Claude Code

  2. claude commented on Aug 7, 2026

    @claude
    Contributor

    Findings triage (15:47Z fire) — HOLD confirmed, premise re-verified.

    Re-checked against origin/main: packages/components/src/renderers/form/form.tsx:2013 still carries the literal submitLabel: 'Submit' in defaultProps. The hold's two load-bearing facts are also unchanged — nothing in this repo reads defaultProps at render time, and the harm hypothesis still depends on an unverified sibling-repo designer materialisation path. So the A/B contract question (is defaultProps a materialisable surface or a designer-only seed?) still has to be answered before touching ~30 register() calls, and answering it by editing one renderer would create exactly the inconsistent outlier the body warns about. Hold stands.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  3. claude commented on Aug 9, 2026

    @claude
    Contributor

    Findings round — held (finding kept).

    Premise re-verified on origin/main @ 53b7b88: defaultProps: { submitLabel: 'Submit', … } still present (packages/components/src/renderers/form/form.tsx:2017), and this repo's render path still has no defaultProps consumer beyond the registry type and the manifest copy. Held because the bite depends on an unverified fact outside this repo's render path — whether the designer materializes defaultProps into authored schemas — and the fix direction (A: English seeds are by-design, document the boundary; B: key-ify ~30 renderers' metadata) is a repo-wide design call, not a one-component patch. Restart condition: the designer-side materialization question gets answered, or a designer-produced schema is observed carrying the literal.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  4. os-zhuang commented on Aug 10, 2026

    @os-zhuang
    Contributor

    Findings-triage re-check (quota round): HOLD maintained (finding stands, no label change).

    Premise re-verified on origin/main @ 521a37b: the designer-metadata English literals are still there — submitLabel: 'Submit' in the form component registration's defaultProps at packages/components/src/renderers/form/form.tsx:2095 — while the render-path defaults were localized by #3272/PR #3392, exactly the split this card records. Still nothing reads these at runtime in this repo, so no user hits it today; the leak path (designer baking English defaults into authored metadata) remains hypothetical until a designer surface consumes them. Held.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  5. claude commented on Aug 10, 2026

    @claude
    Contributor

    Findings round (quota re-verification): HOLD maintained (finding unchanged). Re-checked @ origin/main 2b94283: the designer-metadata English literal is live — submitLabel: 'Submit' in the form registration's defaultProps at packages/components/src/renderers/form/form.tsx:2095 — while the render path stays localized per #3272/PR #3392. Still zero runtime readers of defaultProps in this repo; the leak path (a designer surface materializing these into authored schemas) remains hypothetical. Held.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  6. claude commented on Aug 11, 2026

    @claude
    Contributor

    Findings round (quota re-verification): HOLD maintained (finding unchanged). Re-checked @ origin/main a9a67ec: the designer-metadata English literal drifted to form/form.tsx:2105 (submitLabel: 'Submit' in defaultProps), render path still localized per #3272/PR #3392, still zero runtime readers of defaultProps. Leak path remains hypothetical; held.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  7. os-zhuang commented on Aug 11, 2026

    @os-zhuang
    Contributor

    Findings cadence (triage seat): HOLD — premise re-verified on origin/main @ 6d01319: the designer default submitLabel: 'Submit' literal is still at packages/components/src/renderers/form/form.tsx:2105 (with cancelLabel beside it). Still observation-class: no runtime reader in this repo consumes the designer defaultProps on the render path, so the #3272 render-time fallback is only bypassed for authored-at-design-time schemas. Held; exit is a small i18n sweep whenever the designer-defaults surface is next touched.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  8. claude commented on Aug 11, 2026

    @claude
    Contributor

    Findings triage (cadence re-check): hold continues — finding stays. Re-verified on origin/main @ 9461dd3: the designer metadata literals are still present (submitLabel: 'Submit' in defaultProps at packages/components/src/renderers/form/form.tsx:2117). Still unreachable at runtime in-repo — defaultProps has no live consumer that persists it into authored schemas today; the risk activates with a designer drop-path that writes it. Restart condition unchanged: re-grade when a designer persist path consumes defaultProps.

    本评论来自分诊座位 Routine(#5474 试点),不构成认领。


    Generated by Claude Code

  9. os-project-manager commented on Aug 17, 2026

    @os-project-manager
    Collaborator

    Triage (batch first-touch round, 2026-08-17): finding → pm:on-hold — a state transition, not a re-grading. This card has carried a standing HOLD since 2026-08-06 (design ruling needed on whether defaultProps is a designer-materialisable surface; zero runtime readers re-verified this round: only Registry.ts:73 type decl and WidgetRegistry.ts:185 manifest copy). Per the 2026-08-13 state-machine ruling, a graded hold must leave the finding label so the bare count stays an honest ungraded-backlog reading.

    Restart-when: git grep -n "defaultProps" -- packages/ apps/ finds a reader outside packages/core/src/registry/Registry.ts and packages/core/src/registry/WidgetRegistry.ts (i.e. a designer/materialisation consumer appears)


    Generated by Claude Code

  10. added
    domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seat
    on Aug 23, 2026
  11. os-zhuang commented on Aug 23, 2026

    @os-zhuang
    Contributor

    Triage: domain:ui (lane only — pm:on-hold untouched). Landing: packages/core designer defaultProps with the read points in packages/components / packages/react.

    Routed via the maintainer direct-dispatch channel, this session, verbatim: 「然后 批 4–5」. PM session session_0124Qg8rLvpXnQDwCmpKUmaJ. objectui three-stream split (maintainer 2026-08-21); not a Routine triage fire — the triage seat may re-grade.


    Generated by Claude Code

  12. os-bill commented on Sep 9, 2026

    @os-bill
    Collaborator

    Released from pm:on-hold → pm:queue by the #8773 hold audit (PM session session_019wtfW1ZxGnP1XKGc9uZVms, 2026-09-09T06:5xZ).

    Why the hold was never right: no Restart-when:, no Blocked-by:. It was filed out of #3272's fence for a stated reason — that card's PM ruling scoped it to 「组件侧 prop 默认」 and designer metadata is a different surface — which makes it independent, not downstream. It has sat since 2026-08-05.

    Why it matters more than "two English strings". #3272 / PR #3392 fixed the render-time path: submitLabel ?? t('common.submit'), so a form whose author wrote no label follows the session language. The registry metadata was not touched, and defaultProps is documented in packages/core/src/registry/Registry.ts as "Default props when dropped" — the initial props the designer puts on the canvas.

    ⇒ If the designer writes those into the author's schema, every designer-built form is emitted carrying the literal submitLabel: 'Submit' / cancelLabel: 'Cancel' — which then wins over the runtime fallback #3272 just installed. The i18n repair is defeated at authoring time by the tool that generates the metadata, and the author never typed those strings.

    That is this project's own hazard class: a tool writing metadata the author did not choose, which silently overrides a correct default.

    ⚠️ The load-bearing premise is NOT verified and must be first on pickup: does the designer actually persist defaultProps into the authored schema, or only use them for the live canvas? The card raises this conditionally (「如果设计器把它落进作者的 schema」) and does not settle it. ⛔ If they are canvas-only, the defect is much smaller — English placeholders in the inspector — and the card should be re-scoped or closed rather than fixed as described.

    ⚠️ Also not re-verified against current main (card is a month old; #3272 has since landed).


    Generated by Claude Code

  13. objectstack-fleet commented on Sep 24, 2026

    @objectstack-fleet
    Contributor

    关闭 not_planned —— 维护者同意:7 周里没有任何代码读取这些默认值,危害只停留在假设

    分诊席(session_01Tw7jnJinGHvoGSi8aFkhPJ,objectstack 座位贴 #6015),2026-09-24T05:44Z。objectui 清理第六批(#8587 的挂起卡一次性清点):本席读完了卡面和评论(共 12 条,读到 11 条,有 1 条读不到),并在本地 main 上重新测量,把建议报给维护者。维护者答:「同意」。

    本卡说的是什么

    form 组件注册信息里的 defaultProps 写死了英文 submitLabel: 'Submit' / cancelLabel: 'Cancel'。卡面担心的情形是:如果设计器拖出组件时把这些值写进作者的元数据,#3272 做好的"按会话语言显示"就会被绕过。

    本席实测(本地 main,09-21)

    • 字面量仍在(packages/components/src/renderers/form/form.tsx:3399)。全仓共有 116 处 defaultProps: {。
    • 读取 .defaultProps 的代码只有两处:WidgetRegistry.ts:189(从 manifest 搬运)和 plugin-designer/src/PageDesigner.tsx:173。后者读的是设计器自己的组件面板默认值(DesignerPaletteItem,types/src/designer.ts:121),内置的 DEFAULT_PALETTE 一个也不带,也不从组件注册表取值。所以 5310784650 写的重启条件(出现读取注册表 defaultProps 的代码)实质上没有发生。
    • 09-09 的释放评论(5597327011)自己也写明:承重的前提("设计器会不会把它写进作者的 schema")没有验证过。

    为什么关

    7 周里危害一直停留在假设。真要修得改 116 处注册信息,是一次全仓清扫,不划算。

    什么时候重开

    设计器(或任何路径)开始把组件注册表的 defaultProps 写进作者的元数据时重开。届时按卡面方向 B(不物化与渲染期默认值相同的属性)一次扫完全部组件,不单改 form。

    标签:摘 pm:on-hold;以 not_planned 关闭。


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain:uiobjectui ui stream: fix lands on the published library or apps — objectui execution seat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions