-
Notifications
You must be signed in to change notification settings - Fork 8k
feat: setValues合并算法支持嵌套对象赋值,解决嵌套对象无法正常初始化问题 #6352
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
base: main
Are you sure you want to change the base?
Conversation
|
WalkthroughThe update replaces the previous object merging utility in the form API with a custom deep merge function and introduces a new helper to pick specific fields from objects using nested paths. The Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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: 0
🧹 Nitpick comments (1)
packages/@core/ui-kit/form-ui/src/form-api.ts (1)
368-397
: Consider adding support for array indices in field paths.The current implementation doesn't support array indices in paths (e.g., 'items.0.name'). If your form schemas use array fields with indexed access, consider extending the function to handle numeric keys.
Would you like me to provide an implementation that supports array indices in field paths?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@core/ui-kit/form-ui/src/form-api.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/@core/ui-kit/form-ui/src/form-api.ts (2)
packages/@core/base/shared/src/utils/inference.ts (1)
isObject
(160-160)packages/@core/base/shared/src/utils/date.ts (2)
isDate
(20-22)isDayjsObject
(24-26)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Test (windows-latest)
- GitHub Check: Check (ubuntu-latest)
- GitHub Check: Check (windows-latest)
- GitHub Check: Lint (windows-latest)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (3)
packages/@core/ui-kit/form-ui/src/form-api.ts (3)
295-351
: LGTM! The deep merge implementation handles nested objects correctly.The
fieldMergeFn
function properly implements deep merging with appropriate handling for arrays, Date/Dayjs objects, and null/undefined values. This aligns well with the PR objective of supporting nested object assignment.
399-403
: Well-structured implementation for filtered nested object merging.The approach of first merging with
fieldMergeFn
and then filtering withpickFields
ensures that nested objects are properly merged while maintaining schema integrity. This effectively solves the nested object initialization problem mentioned in the PR objectives.
379-379
: Fix the falsy value handling in field extraction.The condition
value && typeof value === 'object'
will incorrectly skip falsy values like0
,false
, or empty strings. This could lead to data loss when extracting fields with falsy values.Apply this diff to fix the falsy value handling:
- if (value && typeof value === 'object' && key in value) { + if (value !== null && value !== undefined && typeof value === 'object' && key in value) {Likely an incorrect or invalid review comment.
能否提供一个测试demo |
setValues合并算法支持嵌套对象赋值,解决嵌套对象无法正常初始化问题
Summary by CodeRabbit
New Features
Bug Fixes