Skip to content

fix(components): 把字段 label 转发给内置 textarea 的全屏编辑对话框 (#3393) - #3399

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-3393-fullscreen-label-prop
Aug 5, 2026
Merged

fix(components): 把字段 label 转发给内置 textarea 的全屏编辑对话框 (#3393)#3399
yinlianghui merged 1 commit into
mainfrom
claude/issue-3393-fullscreen-label-prop

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

Fixes #3393

前提复核(对 origin/main@9cbcbf478,#3392/#3397 落地之后)

issue 的前提机械可复核,复核结论:成立renderFieldComponent 唯一调用点的 props 对象里没有任何 label: 键 —— 它显式补了 field / inputType / options / placeholder / disabled / readonly / emptyHint / dataSource / dependentValues / dependsOnLabels / error / aria-required,唯独没有 label;而上游 renderFormField 早在 ...fieldProps 之前就把 label 单独解构走了(它要渲染字段自己的 FormLabel)。于是内置 textarea 分支里 const { mobile_fullscreen, label } = fieldProps 拿到的 label 恒为 undefined,FullscreenTextarea 中两条依赖它的表达式从写下那天起没走到过。

但 issue 关于「strip 已经挡着 label」的那半句不成立,这一点改变了修法的形状:stripRendererOnlyPropsstripRegisteredFieldProps都没有 label 条目。真正拦着的只有内置 textarea 分支自己那句 const { label: _label, ...rest },它只护住这一个分支。所以「只在调用点补一个 label」是不够的 —— 那样会让 label 立刻变成 input / textarea / checkbox / switch / 默认分支上的杂 DOM 属性 label="备注"(每个分支都把剩余 props 直接摊到 DOM 节点上),并且会凭空多送注册型 widget 一个新 prop。

改了什么

  1. 调用点显式转发 label(与 placeholder / emptyHint 同法)。这是唯一的行为改动。
  2. label 定性为 renderer-only,两个 strip 各加一条丢弃项:
    • stripRendererOnlyProps —— 字段的 label 由 FormLabel 渲染在控件上方,DOM 属性上不需要第二份;
    • stripRegisteredFieldProps —— 注册路径的载荷与改动前逐字节相同。自 v17 起 field 是 widget 唯一的元数据载体(fieldschema 是同一个意思的两个载体,~25 个 widget 读 field || schema #3233),label 本来就在那里。不加这条,注册型 widget 会突然多收到一个 label prop,并顺着它们的 ...props 摊到七个 widget 的 DOM 上;要不要在 FieldWidgetPropsSchema 里发布 label prop 是另一次裁决,本单不开这个口。
  3. 删掉 textarea 分支里那句 const { label: _label, ...rest }。它本想拦 label 落 DOM,但既然从来没有 label 送进来,它拦的是不存在的东西(ESLint 一直报着 '_label' is assigned a value but never used),而且只护一个分支。现在这件事由 strip 统一负责,所有内置分支同等受护。
  4. RenderFieldProps 上把 label?: string 显式声明出来(与 error 同法),让「转发什么、给谁看」写在类型上而不是靠索引签名兜住。

十个语言包零改动:#3272/PR #3392form.fullscreen.toggle 做成了带 {{label}} 插值的整句(zh 插句尾、ja 插句首),label 一通,十个语言的句子直接就对。

测试

新增 form-fullscreen-textarea-label.test.tsx(9 例),覆盖两个方向:label 送到了(标题 = 字段名而非通用词;按钮无障碍名插值;一张表单三个长文本字段的按钮名互不相同,且第二个按钮打开的是第二个字段的对话框;zh 下整句正确),以及 label 只送到了那里(所有内置分支渲染出的 DOM 上没有任何 label 属性;注册型 widget 的 props 里 props.label 为 undefined 而 props.field.label 仍是「Notes」)。

form-fullscreen-textarea-i18n.test.tsx 的 fixture 从「有 label」改成「无 label」:这一组的被测对象是两个通用串(form.fullscreen.title 与被插值的 form.fullscreen.textFallback),而通用串只在字段没有 label 时可达。写这组用例时字段叫 Notes 却仍显示通用词,正是本单修掉的缺陷 —— 把 fixture 指向 fallback 真正服务的那个栈,这十个语言包才继续被覆盖,而不是继续断言一个已修的缺陷。提交 draft 那一例仍用带 label 的 fixture(它断言的是接线而不是文案)。

反向验证(三条肢,方向各自预先判定,结果与预判一致)

拆掉的东西 预判 实测
调用点的 label, 对话框相关 5 例红,fallback / DOM / 注册路径 3 例保持绿,i18n 组全绿 5 failed / 8 passed;报错正是缺陷本身:expected [ 'Edit text fullscreen', …(2) ] to deeply equal [ 'Edit Notes fullscreen', …(2) ]
stripRendererOnlyPropslabel 仅 DOM 属性一例红 1 failed / 8 passed:expected input …(8) ...
stripRegisteredFieldPropslabel 仅注册路径探针一例红 1 failed / 8 passed:expected 'Notes' to be undefined

i18n 组在第一条肢下保持全绿,是这次 fixture 改判正确的独立证据:它已经不再依赖缺陷行为。

跑过的命令

仓根跑(包内 --root packages/components + 相对路径过滤会命中 objectui#3288/#3378 的假绿:No test files found, exiting with code 0,退出码 0):

  • npx vitest run --maxWorkers=2 packages/components/src/renderers/form/ packages/components/src/__tests__/form-renderers.test.tsx packages/components/src/__tests__/form-write-error-message.test.tsxTest Files 30 passed (30) / Tests 177 passed (177)
  • 消费半径扫到 packages/fields 的三个 e2e 门禁(其中 widget-dom-leak-e2e 就是注册型 widget 的 DOM 泄漏门禁): → Test Files 3 passed (3) / Tests 294 passed (294)
  • pnpm --workspace-concurrency=2 --filter @object-ui/components type-check → 通过(tsc --noEmit && tsc -p tsconfig.typetests.json,无输出)
  • npx eslint packages/components/src/renderers/form/form.tsx → 0 errors。warning 数 89 → 90:textarea 分支那条 '_label' ...never used 消失了,strip 两函数各多一条同类 warning。这与 issue 的预期略有出入,如实记录:_label 的告警不是消失,而是搬了家 —— 该文件里每一个 strip 绑定(_dataSource / _inputType / _schema …)本来就各报一条同类 warning,新增两条与既有约定完全一致。
  • pnpm run check:control-bytes → OK(3587 个文件);另按 AGENTS.md 对改动文件做了越过门禁的自扫 grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]' → 干净。

范围

只动 packages/components/src/renderers/form/form.tsx + 相应测试 + 一个 patch changeset。⛔ 未改注册路径的对外契约(载荷逐字节不变),⛔ 未碰 packages/fieldsFullscreenFieldEditor(#3398 另议)。


🤖 Generated with Claude Code

https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt


Generated by Claude Code

`renderFormField` 解构字段配置时把 `label` 单独取走(它要渲染
`<FormLabel>`),而唯一的 `renderFieldComponent` 调用点重建 props 对象时
补回了 field/inputType/options/placeholder/emptyHint/dependsOnLabels,
唯独漏了 `label`。内置 `textarea` 分支的 `label` 因此恒为 undefined,
`FullscreenTextarea` 里两条依赖它的分支从未走到:对话框标题恒为通用词
「编辑文本」,展开按钮的无障碍名在同一表单的三个长文本字段上完全一样。

- 调用点显式转发 `label`(与 placeholder/emptyHint 同法)。
- `label` 为 renderer-only:两个 strip 各加一条丢弃项,既不落 DOM 属性,
  也不进注册路径(FieldWidgetProps 契约不变,widget 仍从 `field` 读)。
- 删掉 textarea 分支里那句只护一个分支、且从来没东西可护的
  `const { label: _label, ...rest }`。

十个语言包零改动:#3272 已把 `form.fullscreen.toggle` 做成带 {{label}}
插值的整句;无 label 的字段仍回落到被翻译的通用词。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 5, 2026 5:13pm

Request Review

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 28.1 KB 350 KB
Entry file index-n3I40y3D.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 8.47KB 3.09KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 7.57KB 2.97KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.13KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.64KB 2.21KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 18.38KB 4.49KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 3.65KB 1.42KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.25KB 0.53KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 478.19KB 104.98KB
core (index.js) 2.25KB 0.80KB
create-plugin (index.js) 9.28KB 2.98KB
data-objectstack (index.js) 136.23KB 34.75KB
fields (index.js) 227.18KB 55.72KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 2.65KB 1.06KB
i18n (pickLocalized.js) 1.70KB 0.83KB
i18n (provider.js) 9.48KB 3.27KB
i18n (useObjectLabel.js) 26.14KB 6.07KB
i18n (useSafeTranslation.js) 3.26KB 1.44KB
layout (index.js) 38.53KB 10.71KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.05KB 1.53KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.71KB 3.79KB
plugin-calendar (index.js) 44.98KB 12.37KB
plugin-charts (index.js) 61.04KB 17.31KB
plugin-chatbot (index.js) 180.09KB 42.72KB
plugin-dashboard (index.js) 112.01KB 28.86KB
plugin-designer (index.js) 210.51KB 42.51KB
plugin-detail (index.js) 231.54KB 57.09KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 111.54KB 26.97KB
plugin-gantt (index.js) 162.55KB 39.57KB
plugin-grid (index.js) 185.08KB 49.04KB
plugin-kanban (index.js) 47.89KB 13.18KB
plugin-list (index.js) 105.02KB 25.36KB
plugin-map (index.js) 16.81KB 5.24KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 40.55KB 10.59KB
plugin-timeline (index.js) 25.76KB 7.33KB
plugin-tree (index.js) 8.34KB 2.82KB
plugin-view (index.js) 83.67KB 20.43KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 19.28KB 6.38KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.02KB 0.55KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 2.46KB 1.21KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 0.20KB 0.18KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

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

Projects

None yet

2 participants