-
Notifications
You must be signed in to change notification settings - Fork 269
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
fix(FormItem): 修复initialValue属性初始化未被正确加入到Formstore中导致的问题 #2247
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #2247 +/- ##
=======================================
Coverage 85.78% 85.79%
=======================================
Files 217 217
Lines 22783 22795 +12
Branches 2481 2485 +4
=======================================
+ Hits 19545 19557 +12
Misses 3233 3233
Partials 5 5 ☔ View full report in Codecov by Sentry. |
Walkthrough此次更新主要集中在表单和表单项的初始值设置功能。为表单项和表单添加了初始值的测试,并在 Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (3)
Files skipped from review as they are similar to previous changes (3)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 2
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/packages/formitem/formitem.taro.tsx (2 hunks)
- src/packages/formitem/formitem.tsx (1 hunks)
Additional Context Used
GitHub Check Runs (1)
codecov/patch failure (2)
src/packages/formitem/formitem.tsx: [warning] 82-82: src/packages/formitem/formitem.tsx#L82
Added line #L82 was not covered by tests
src/packages/formitem/formitem.tsx: [warning] 84-85: src/packages/formitem/formitem.tsx#L84-L85
Added lines #L84 - L85 were not covered by tests
Additional comments not posted (6)
src/packages/formitem/formitem.tsx (3)
76-85
: 代码看起来不错!请确保所有调用setFieldsValue
的地方都符合新的逻辑。
Line range hint
111-111
: 代码看起来不错!
Line range hint
157-157
: 代码看起来不错!src/packages/formitem/formitem.taro.tsx (3)
76-85
: 代码看起来不错!请确保所有调用setFieldsValue
的地方都符合新的逻辑。
111-111
: 代码看起来不错!
Line range hint
157-157
: 代码看起来不错!
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.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/packages/form/tests/form.spec.tsx (1 hunks)
Additional comments not posted (3)
src/packages/form/__tests__/form.spec.tsx (3)
25-36
: 新增的测试用例验证了在Form.Item
中设置initialValue
的功能,测试逻辑正确。
38-49
: 新增的测试用例验证了在Form
和Form.Item
中同时设置initialValue
的功能,测试逻辑正确。
38-49
: 新增的测试用例验证了在Form
和Form.Item
中同时设置不同的initialValue
的功能,测试逻辑正确。
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.
需要覆盖到 reset 方法
src/packages/formitem/formitem.tsx
Outdated
@@ -73,6 +73,10 @@ | |||
} | |||
|
|||
componentDidMount() { | |||
const { setFieldsValue } = this.context | |||
if (this.props.initialValue) { | |||
setFieldsValue({ [this.props.name || '']: this.props.initialValue }) |
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.
应该使用 setInitialValues,来设置初始值,并需要检查 初始值中是否已经设置过此字段,如果设置了,则跳过 formitem 的设置逻辑。可以参考 form 设置 initialvalues 的方式。
Taro和H5同样的改动
Summary by CodeRabbit
新功能
测试