fix(components): #3344 Combobox trigger 显式声明 type="button",绝不提交外层表单 - #3349
Merged
Conversation
…r submits an enclosing form Inside a <form> a bare <button> defaults to type="submit". The Combobox trigger relied on Radix PopoverTrigger's Slot-supplied type="button" for form safety — an upstream implementation detail, now declared locally as a regression-tested contract. The default sits before the #3318 pass-through spread so an explicit consumer `type` still overrides. Co-Authored-By: Claude Fable 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
Author
|
全量 components 包测试补录(push 后按 push-first 纪律补跑): ✅ 全绿,无回归。 Generated by Claude Code Generated by Claude Code |
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 #3344
修复内容
按 PM 裁决(#3344 认领评论):给
packages/components/src/custom/combobox.tsx的 trigger Button 加一行type="button",且放在 #3318 引入的 pass-through spread({...triggerProps})之前 —— 消费方显式传type(如type="submit")时覆盖仍然生效。附带回归测试钉住两个方向的契约。写好回归测试后先对未修复的源码跑(破坏验证的红腿),3 个用例全绿 —— 追查发现当前安装的
@radix-ui/react-popover@1.1.23的PopoverTrigger本身就渲染type: "button"(在其 props spread 之前),经asChild的 Slot 合并落到我们的 Button 上。issue 的前提「Radix PopoverTrigger 不设 type」对该版本不成立:type="button",form 内点击不会提交(实测断言通过);type="submit"时,子元素 prop 压过 Slot prop,覆盖本来就生效。因此本 PR 的实际性质是防御性加固 + 契约钉住:form 安全此前只由上游实现细节保证(Radix 换版本/重构掉 asChild 即失守),现在升格为本地显式声明、有回归测试把守的契约 —— 与 LookupField / MultiSelectField / RatingField 的显式写法对齐。是否要把 #3344 重新归类(bug → 加固),请 PM 定夺。
验证表
pnpm exec vitest run packages/components/src/__tests__/combobox-trigger-type.test.tsx packages/components/src/__tests__/combobox-long-label.test.tsx --maxWorkers=2pnpm exec turbo run type-check --filter=@object-ui/components破坏验证实录
type="button"。type={undefined},模拟上游无兜底且本地无声明)**→ 2 red(缺省用例toHaveAttribute('type', 'button')失败;覆盖用例type="submit"属性断言失败)→ 还原 → 绿。证明回归测试确实把守该契约。onSubmit被调用 1 次),故缺省用例的not.toHaveBeenCalled()是有效行为断言,不是恒真。Changeset
@object-ui/componentspatch(fixed group,未声明 major)。未触碰content/docs/releases/。🤖 Generated with Claude Code
https://claude.ai/code/session_01NVPjPzmmAJ2Ngtvgg5MSRa
Generated by Claude Code