Skip to content

fix(uniapp): preserve empty string values in Radio and Checkbox - #4607

Open
luppyw wants to merge 1 commit into
Tencent:developfrom
luppyw:fix/issue-4604-empty-value
Open

fix(uniapp): preserve empty string values in Radio and Checkbox#4607
luppyw wants to merge 1 commit into
Tencent:developfrom
luppyw:fix/issue-4604-empty-value

Conversation

@luppyw

@luppyw luppyw commented Aug 14, 2026

Copy link
Copy Markdown

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Closes #4604

💡 需求背景和解决方案

UniApp 公共 props 处理器会将联合类型中的 Boolean 移到首位,使 Radio 和 Checkbox 声明的 [String, Number, Boolean] 变成 [Boolean, String, Number]。Vue 因此会将 value="" 按布尔属性转换为 true

本 PR 保留 props 声明中的原始类型顺序,使空字符串继续作为字符串传递,同时避免公共处理器原地修改类型数组。新增 Radio 和 Checkbox 回归测试,并将 UniApp 测试目录纳入现有 Jest 配置。

验证结果:

  • UniApp lint:0 errors(8 个既有 warnings)
  • 单元测试:139 suites、790 tests、397 snapshots 全部通过
  • pnpm build:uniapp 构建通过
English version

The shared UniApp props normalizer moved Boolean to the front of union types. This changed the Radio and Checkbox value declaration from [String, Number, Boolean] to [Boolean, String, Number], causing Vue to cast value="" to true.

This PR preserves the declared prop type order so empty strings remain strings and the original type arrays are not mutated. It also adds regression coverage for Radio and Checkbox and includes UniApp tests in the existing Jest configuration.

Verification:

  • UniApp lint: 0 errors (8 pre-existing warnings)
  • Unit tests: 139 suites, 790 tests, and 397 snapshots passed
  • pnpm build:uniapp passed

📝 更新日志

  • 本条 PR 不需要纳入 Changelog

tdesign-miniprogram

@tdesign/uniapp

  • fix(Radio/Checkbox): 修复 value 为空字符串时被转换为 true 的问题

@tdesign/uniapp-chat

☑️ 请求合并前的自查清单

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须补充

@luppyw

luppyw commented Aug 14, 2026

Copy link
Copy Markdown
Author

@PengYYYYY 方便时能否帮忙审核一下这个 PR?如果实现思路和修改没有问题,并且必要检查通过,辛苦帮忙合并一下;如有任何建议,我会及时跟进调整。感谢!

English version

Could you please review this PR when you have time? If the implementation and changes look correct and the required checks pass, would you be willing to merge it? I will address any feedback promptly. Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t-radio 的value="" 时获取到的值时true

1 participant