-
-
Notifications
You must be signed in to change notification settings - Fork 50.5k
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
feat: Support requiredMarkType #26309
Conversation
有点纠结这个 API 名字,更好的应该是 cc @ant-design/ant-design-collaborators |
@@ -75,6 +75,7 @@ const localeValues: Locale = { | |||
back: '返回', | |||
}, | |||
Form: { | |||
optional: '(可选)', |
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.
最好 Form 级别也可配,有些地方用 选填
。
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.
这个是 locale,属性来自 Form 的 requiredMarkType
,预览好了我贴一下链接方便理解。
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.
我意思是每个 Form 对这个属性可以有控制权。
我的想法:
Item 继承 Form,可单独配置。 不过,这样好像把 required 从 rules 提出来了。。。。 |
requiredType 字面上容易让人脑补出其他意思。 如果未来能传 ReactNode 建议直接用 requireMark。 requiredMarkType 建议,用户都写了那么多代码了,而且还有智能提示,还是看的明白比较重要。 |
Size Change: +592 B (0%) Total Size: 787 kB
|
- requireMarkType
+ requiredMarkType |
d764bb9
to
45e0276
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d764bb9:
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ab5bd14:
|
|
|
文档移除还是废弃掉吧 不然感觉有歧义 |
隔几个版本再 warning,否则用户升级一脸懵逼怎么到处都是 warning 也不好。 |
Codecov Report
@@ Coverage Diff @@
## feature #26309 +/- ##
===========================================
+ Coverage 99.56% 99.57% +0.01%
===========================================
Files 375 375
Lines 7316 7335 +19
Branches 1997 2005 +8
===========================================
+ Hits 7284 7304 +20
+ Misses 32 31 -1
Continue to review full report at Codecov.
|
done |
// Optional mark | ||
.@{form-item-prefix-cls}-optional { | ||
display: inline-block; | ||
margin-left: @margin-xss; |
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.
这个 有对应的 RTL 吗?
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.
👌
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.
我启动看一下
我直接改了 |
记得 changeLog 更新一下。 |
@@ -65,17 +82,18 @@ const InternalForm: React.ForwardRefRenderFunction<unknown, FormProps> = (props, | |||
const { __INTERNAL__ } = wrapForm; | |||
__INTERNAL__.name = name; | |||
|
|||
const formContextValue = React.useMemo( | |||
const formContextValue = useMemo<FormContextProps>( |
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.
这地方有必要 useMemo 吗?感觉不是很费性能。是内部还依赖这个值的引用?
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.
之前有相关 issue 中间加了 memo 还是会被上层 context 变化触发渲染
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.
之前有相关 issue 中间加了 memo 还是会被上层 context 变化触发渲染
没理解,加了还触发的意思不就是加不加都差不多嘛?是说不加才触发渲染吗
[中文版模板 / Chinese template]
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
📝 Changelog
requiredMark
.requiredMark
属性以支持设置必选样式。☑️ Self Check before Merge
View rendered components/form/demo/required-mark.md
View rendered components/form/index.en-US.md
View rendered components/form/index.zh-CN.md