Skip to content

fix(checkbox): clean up group value registration - #894

Merged
selicens merged 2 commits into
antdv-next:mainfrom
yunfeizhu:fix/checkbox-group-unregister
Sep 17, 2026
Merged

selicens merged 2 commits into
antdv-next:mainfrom
yunfeizhu:fix/checkbox-group-unregister

Conversation

@yunfeizhu

Copy link
Copy Markdown
Contributor

🤔 本次变更属于 ...

  • 🐞 Bug 修复
  • ✅ 测试用例

🔗 相关 Issue

Fixes #893

💡 背景与方案

CheckboxGroup 初始选中 A,移除 A 后再勾选 B,change 和 update:value 仍会返回 ["A", "B"],而不是 ["B"]。使用 options 或条件渲染的 Checkbox 子项时均可复现。

目前初始值在 watcher 外注册,而卸载清理只在非 immediate 的 watcher 回调中设置。若 value 和 skipGroup 没有变化,组件卸载时便不会注销初始值。

将注册与清理统一到 immediate watcher 中,清理时使用该次注册的值。这样首次挂载、value 变化、skipGroup 切换和卸载都能正确维护分组成员。移除选项本身不会主动改写父组件的受控值;后续用户操作触发的事件会过滤掉已移除的值。

验证:

  • 新增 8 个回归场景,覆盖受控/非受控、options/slots、动态 value、skipGroup 和重新挂载。修复前 7 个失败,修复后全部通过。
  • Checkbox、Table、Transfer 相关测试:373 passed。
  • 修改文件 ESLint、git diff --check、antdv-next ESM 与声明文件构建通过。
  • 本地浏览器复验:移除 A 后勾选 B,change 和 v-model:value 均为 ["B"]。

📝 变更日志

语言 变更日志
🇺🇸 英文 Fix CheckboxGroup retaining removed checkbox values in change and update:value events, and keep registration in sync when value or skipGroup changes.
🇨🇳 中文 修复 CheckboxGroup 在 change 和 update:value 事件中保留已移除选项值的问题,并在 value 或 skipGroup 变化时正确维护选项注册。

@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

@yunfeizhu is attempting to deploy a commit to the aibayanyu20's projects Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Sep 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

antdv-next

pnpm add https://pkg.pr.new/antdv-next@894
npm i https://pkg.pr.new/antdv-next@894
yarn add https://pkg.pr.new/[email protected]

@antdv-next/cssinjs

pnpm add https://pkg.pr.new/@antdv-next/cssinjs@894
npm i https://pkg.pr.new/@antdv-next/cssinjs@894
yarn add https://pkg.pr.new/@antdv-next/[email protected]

commit: 0b504b5

@github-actions

Copy link
Copy Markdown

Size Report

File Size Gzip Brotli
dist/antd.js 2.0 MB → 2.0 MB (-122 B, -0.0%) 532 kB → 532 kB (-24 B, -0.0%) 406 kB → 406 kB (+10 B, +0.0%)
dist/antd.esm.js 2.7 MB → 2.7 MB (-110 B, -0.0%) 618 kB → 618 kB (-25 B, -0.0%) 458 kB → 458 kB (+34 B, +0.0%)

@selicens
selicens merged commit a4244f9 into antdv-next:main Sep 17, 2026
12 of 13 checks passed
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.

[Checkbox] CheckboxGroup 移除已选选项后,change 和 v-model 仍包含已卸载的值

3 participants