refactor(fields): TextAreaField reads mobile_fullscreen from one source (#3232) - #3244
Merged
Merged
Conversation
…ce (#3232) The widget resolved its fullscreen affordance through a four-way `??` chain: a `mobileFullscreen` (camelCase) prop, `field.mobile_fullscreen`, a `mobile_fullscreen` prop, and `schema.mobile_fullscreen`. Three of the four were permanently `undefined`: - `mobileFullscreen` had no producer anywhere in the repo — the only two occurrences of that spelling were this widget's own read and the destructure that kept it off the DOM spread. The doc comment claimed "the host form passes `mobileFullscreen`", so it documented a contract that never held. - `mobile_fullscreen` as a prop cannot arrive: `stripRegisteredFieldProps` (components/src/renderers/form/form.tsx) removes it, and `fullscreen`, from the props forwarded to registered field widgets. - `schema.mobile_fullscreen` restates the object `field || schema` already resolves into `textareaField`. What is left is the one live source: the field metadata flag ObjectForm stamps onto long-text fields from `ObjectFormSchema.mobile.fullscreenLongText`. The doc comment now describes that, names the producer, and records why there is deliberately no host-override prop. No behaviour change. The metadata path is pinned by new tests covering the button, the dialog and the committed edit, so the cleanup cannot have removed the working affordance; the retired spellings are pinned inert at compile time (they are not on the closed `FieldWidgetComponentProps`, #3221) and at runtime. The built-in (unregistered) `textarea` branch of the form renderer, which reads `mobile_fullscreen || fullscreen` off the form-field props and renders its own `FullscreenTextarea`, is a separate live path and is untouched. Per AGENTS.md #0.1 and Prime Directive #12: divergence converges at the producer, not by accumulating tolerance at the consumer. Fixes #3232 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 free
to 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.
Fixes #3232
做了什么
TextAreaField的全屏入口原本经一条四路??链决定是否显示,现在收敛为唯一一条:字段元数据上的mobile_fullscreen。同时删掉了第 57 行那条只为「把它挡在 DOM spread 之外」而存在的
mobileFullscreen解构,并把文档注释改成描述真实来源。为什么这三条读取可以删
复核了
origin/main @ ca58e45,issue 里的四条断言全部成立:props.mobileFullscreen(camelCase)undefined,删field.mobile_fullscreenplugin-form/src/ObjectForm.tsx:1049,由ObjectFormSchema.mobile.fullscreenLongText推导props.mobile_fullscreencomponents/src/renderers/form/form.tsx:266的stripRegisteredFieldProps()把mobile_fullscreen和fullscreen从转发给已注册 widget 的 props 里剔除props.schema.mobile_fullscreentextareaField = field || props.schema已经把这对载体解析过了所以运行时行为零变化:被删的三条本来就永远是
undefined。注释里那句「宿主表单传入
mobileFullscreen」从来没有成立过 —— 这正是代价所在:下一个作者照着注释去传一个被静默忽略的 prop,不会收到任何反馈。明确没有做的事
没有新增「宿主强制全屏」的 prop 覆盖能力。 issue 结尾那句「如果确实需要」是个假设句;今天没有任何宿主需要它,凭空造一个没有生产者的键,恰恰是主令 #12 禁止的同一个错误换个方向犯。真需要时的正确做法写进注释了:在
FieldWidgetComponentProps上声明一个键、让form.tsx停止剥离它、并让某个宿主真的传它。没有动
packages/components/src/renderers/form/form.tsx。 其中form.tsx:1761-1763在内置(未注册) textarea 分支上读mobile_fullscreen || fullscreen并渲染它自己的FullscreenTextarea—— 那是另一条独立的活路径(BUILTIN_FIELD_TYPES命中textarea时走它,不会走到本 widget),本 PR 完全没有触碰,新测试的文件头注释也把这点钉住了,避免下一个人来「顺手统一」。测试
新增
packages/fields/src/widgets/__tests__/TextAreaField.mobileFullscreen.test.tsx,两组共 6 个用例:onChange;外加schema载体(field缺席时)与「没有 flag 就没有入口」两例。@ts-expect-error钉住mobileFullscreen/mobile_fullscreen都不在收紧后的FieldWidgetComponentProps(FieldWidgetComponentProps的[key: string]: any让每个 widget prop 检查失效 #3221)上;运行时钉住即便无类型宿主硬塞进来,入口也不会复活。护栏是真的:把实现临时改回
Boolean((props as any).mobileFullscreen)之后,6 个用例里 4 个立刻转红(含全部三个活路径用例),改回来后恢复全绿。验证输出:
Changeset
.changeset/textarea-mobile-fullscreen-single-source.md,patch(未声明major,符合 AGENTS.md 版本号策略与changeset-guard)。依据:AGENTS.md #0.1(消费者侧宽容会固化出第二套事实契约)与主令 #12(拼写分歧在生产者收敛)。收敛之后,写错的键不再有任何读取路径把它悄悄接住 —— 错误从此是响的。
Generated by Claude Code