select icon indicating copy to clipboard operation
select copied to clipboard

antd v5: Controlled components will treat `null` as empty value and `null` can not be used as an option value.

Open shezhangzhang opened this issue 3 years ago • 5 comments

Changes:

  1. null cannot be used as an option value.
  2. allowClear triggerChange will pass the null to onChange() instead of undefined.
  3. add a new example: null-controlled example. (placeholder will show up)
  4. change some test case for null as an option value.
  5. add prettier latest (2.x) version to devDependencies, because the current prettier version added by umi-utils is 1.x, which can't deal with typescirpt import type syntax (prettier 1.x error: SyntaxError: '=' expected).
  6. add node children & options null value wanrning (/utils/warningPropsUtils.ts).

Chinese (中文):

  1. null 不能作为选项的 value 了。
  2. allowClear 触发清空更新会传递 null 作为空值而不是 undefined
  3. 新增了一个 null 作为 value 初始值的例子(占位符会正确出现,移除了之前的特殊处理逻辑)。
  4. 修改了 null 不能作为 value 相关的几个测试用例。
  5. 添加了 prettier 的最新版本(2.x)到 devDependencies,因为当前由 umi-utils 安装的的 prettier 版本是 1.x, 不能正确处理 typescript 的 import type 语法(prettier 1.x 会报错:SyntaxError: '=' expected)。
  6. 添加了 null 作为 value 出现在 options 中的告警(在 /utils/warningPropsUtils.ts 中)。

shezhangzhang avatar Jun 13 '22 12:06 shezhangzhang

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
select ✅ Ready (Inspect) Visit Preview Jun 14, 2022 at 11:47AM (UTC)

vercel[bot] avatar Jun 13 '22 12:06 vercel[bot]

Codecov Report

Merging #777 (007c0f0) into master (446dd09) will increase coverage by 0.00%. The diff coverage is 100.00%.

:exclamation: Current head 007c0f0 differs from pull request most recent head ecf8223. Consider uploading reports for the commit ecf8223 to get more accurate results

@@           Coverage Diff           @@
##           master     #777   +/-   ##
=======================================
  Coverage   99.50%   99.51%           
=======================================
  Files          25       25           
  Lines        1020     1029    +9     
  Branches      341      337    -4     
=======================================
+ Hits         1015     1024    +9     
  Misses          4        4           
  Partials        1        1           
Impacted Files Coverage Δ
src/Select.tsx 100.00% <100.00%> (ø)
src/utils/warningPropsUtil.ts 98.59% <100.00%> (+0.28%) :arrow_up:
src/Selector/Input.tsx 100.00% <0.00%> (ø)
src/Selector/index.tsx 100.00% <0.00%> (ø)

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

codecov[bot] avatar Jun 13 '22 12:06 codecov[bot]

先到 FAQ 里 PR 一下,说明一下 null 值在 antd 中的定义,以及为什么要这么做哈~

zombieJ avatar Jun 13 '22 13:06 zombieJ

这是 break change,至少 4.x 中不能改。

afc163 avatar Jun 13 '22 13:06 afc163

嗯嗯,这应该是 V5 的 break change。4.x 我先写个 FAQ:null & undefined controlled components 的PR,然后再在这里提个 null warning 的 PR 上来先哇

shezhangzhang avatar Jun 13 '22 13:06 shezhangzhang