New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
antd v5: Controlled components will treat null
as empty value and null
can not be used as an option value.
#777
base: master
Are you sure you want to change the base?
Conversation
… umi-utils is 1.x, which can't deal with ts import type
…ve null instead of undefined value
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
return values; | ||
}, [internalValue, convert2LabelValues, mode]); | ||
|
||
// Fill label with cache to avoid option remove | ||
const [mergedValues, getMixedOption] = useCache(rawLabeledValues, valueOptions); | ||
|
||
const displayValues = React.useMemo(() => { | ||
// `null` need show as placeholder instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since when null
as value will returns [], this logic code is no looger needed. When value={null}
, the placeholder will show up correctly.
因为 null 作为空值已经做了返回 [] 的处理,所以这段特殊处理此 issue 的逻辑已经不需要了,value={null}
时 placeholder 会正确显示。
Codecov Report
@@ 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
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
先到 FAQ 里 PR 一下,说明一下 null 值在 antd 中的定义,以及为什么要这么做哈~ |
这是 break change,至少 4.x 中不能改。 |
嗯嗯,这应该是 |
null
as empty value and null
can not be used as an option value.null
as empty value and null
can not be used as an option value.
Changes:
null
cannot be used as an option value.allowClear
triggerChange will pass thenull
to onChange() instead ofundefined
.null-controlled
example. (placeholder will show up)null
as an option value.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).null
value wanrning (/utils/warningPropsUtils.ts).Chinese (中文):
null
不能作为选项的 value 了。allowClear
触发清空更新会传递null
作为空值而不是undefined
。null
作为 value 初始值的例子(占位符会正确出现,移除了之前的特殊处理逻辑)。null
不能作为 value 相关的几个测试用例。prettier
的最新版本(2.x)到 devDependencies,因为当前由 umi-utils 安装的的 prettier 版本是 1.x, 不能正确处理 typescript 的 import type 语法(prettier 1.x 会报错:SyntaxError: '=' expected)。null
作为 value 出现在 options 中的告警(在 /utils/warningPropsUtils.ts 中)。